misko321
misko321

Reputation: 493

Force Solr not to use _version_ field during search

I have a default declaration for _version_ field in my schema.xml:

<field name="_version_" type="long" indexed="true" stored="true"
   multiValued="false"/>

I've read that this field is only internally managed by Solr for concurrency management, however when I search for "002219" in return I get:

"docs": [  
  {  
        "person_street_t": [  
          "<streetName>",  
        ],  
        "id": "123",  
        "person_abbr_t": [  
          "<sb>"  
        ],  
        "person_name_t": [  
          "<sb>"  
        ],  
        "person_city_t": [  
          "<city>"  
        ],  
        "person_zipcode_s": "<zipcode>",  
        "type_s": "PERSON",  
        "person_house_number_s": "<hn>",  
        "_version_": 1494523490022195200  
                            //****** <- matched by Solr
   }  
 ]  

but I don't want Solr to search through that field. Is it a normal behaviour? Am I doing something wrong? Or is there any other way to disable searching in _version_ field?

UPDATE:

Okay, I've read a bit and found out that this field (_text) is defaultSearchField. So what I did for now is changing the default:

<copyField source="*" dest="_text"/>

to:

  <copyField source="*_t" dest="_text"/>
  <copyField source="*_s" dest="_text"/>
  <copyField source="*_ts" dest="_text"/>
  <copyField source="*_ss" dest="_text"/>

These are the only field types I'm indexing (*_ts was added by me). Will it be sufficient?

Upvotes: 1

Views: 561

Answers (1)

Alexandre Rafalovitch
Alexandre Rafalovitch

Reputation: 9789

If you used example schema, you most probably have copyField defined that copies everything to a single text field (defined in schema.xml) and searches that (defined in solrconfig.xml).

That's good for development, but everything is just searched as text, probably not something you want to do.

You can investigate switching to something like eDisMax. Or, if you are not quite ready, you can just define tighter copyField rules to only aggregate the fields you want.

Upvotes: 1

Related Questions