2

Indexed data on Solr contains some fields which are having empty values. When I run q=*:* it does not include fields having empty values. What parameter do I need to pass while query to get fields having empty values in the result.

EDIT : I am indexing data using a csv file, entries in file are as follows :

id, dob, name
1,,name1
2,,name2

Now when I search for top 10 records I get only two fields. I want to get all fields even if there is no value stored for that.

Lefty G Balogh
  • 1,771
  • 3
  • 26
  • 40
Prometheus
  • 549
  • 1
  • 7
  • 18

4 Answers4

1

Field should have stored="true"

Cross check in your schema.xml file about dob field. it should have stored="true"

<field name="dob" type="text_general" indexed="true" stored="true"/>

reindex the documents and query again, it works.

Hope this help

Vinod
  • 1,965
  • 1
  • 9
  • 18
  • Its a dynamic field, similar to ``. This is what written over ther. – Prometheus Oct 05 '16 at 10:50
  • nothing difference if its dynamic field. if stored="true" then it will come in result set like `"i_dob":""`. Did you reindex ? – Vinod Oct 05 '16 at 10:58
  • The thing is, I can not specify field name in the query, as I don't know the field name at the time of query. Its all automated and there are multiple dynamic fields. – Prometheus Oct 05 '16 at 11:31
  • Ok. you copy *_dob field to text field in schema file using copyfield. like ``. by default solr search in text field which is specified in config file. reindex and try. this might work . – Vinod Oct 05 '16 at 11:41
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/124985/discussion-between-vinod-and-prometheus). – Vinod Oct 05 '16 at 11:45
1

If an item doesn't have a piece of data, solr doesn't store the field. You should be able to force storage of an empty string by setting the field attributes required="True" default="".

GoetzOnline
  • 417
  • 8
  • 22
0

what do you mean empty fields ? are these fields are set as indexed=true ? Are you setting empty say spaces as data when you are indexing these fields ? Looks like you are not sending even a template blank data to this variable , that is why its happening . For example if i send data in this format {"id":"change.me","title":" "} , where my title field is empty it gets indexed .But if you try to send a data like this , {"id":"change.me","title":} , it will send an error across solr .

Saurabh Chaturvedi
  • 2,028
  • 2
  • 18
  • 39
  • 1
    yes all fields are `indexes=true`. I am indexing solr core using a csv file and the data would be something like this for field `id, title,name : 1,,abcd`. I am updating the csv format in my question too. – Prometheus Oct 05 '16 at 08:59
0

Using a query add wt=csv and you can export a well formed CSV file

Specify the fields you require back using fl=

Example: select?fl=id,foo,bar&indent=on&q=field:value&stored=true&rows=1000&start=0&wt=json

roberthuttinger
  • 1,172
  • 1
  • 17
  • 31