0

i need to select all records which have words "6" and "buldings". i'm creating such query to my solr:

/select?q=name:2+AND+buildings 

solr returns me 128 results. most of results have something like "126 buildings" or "buildings 7260" but i need only records with words "6" and "buildings".

but if i change words places in the query:

/select?q=name:buildings+AND+2 

it returns me absolutely another result - the right one! this time there are no strange records with words "7260" or "126" only records that i really need with words "6" and "buildings".

so please can sombody explain to me why solr returns such a strange result in the first case because i create queries without considering that solr can return different results if words places are changed. and how can i point solr to search only "6" if it goes before word?

any help appriciated.

1 Answer 1

1

name:buildings AND 2 is not the same as name:2 AND buildings because the field ("name") is only being applied to the first term in the query. The other is being searched in the default field for the query parser.

  • name:buildings AND 2 is identical to: name:buildings AND defaultfield:2

  • name:2 AND buildings is identical to: name:2 AND defaultfield:buildings

If you want both to be searched in the "name" field, you could use a query like:

name:(2 AND buildings) 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.