Solr AND operator not working

2019-08-17 16:40发布

问题:

http://localhost:8080/products/select?indent=on&q=text:30MM X 533MM Abrasives&fl=*,[docid]

returns docid 187095

http://localhost:8080/products/select?indent=on&q=textfields:30MM X 533MM Abrasives&fl=*,[docid]

returns docid 187095

http://localhost:8080/products/select?indent=on&q=textfields:30MM X 533MM Abrasives AND text:30MM X 533MM Abrasives&fl=*,[docid]

returns no result.

Am I not applying AND correctly ?

回答1:

If you use fielded data in your query and you don't use double quotes ("), the only word being searched in that field is the first one. For example, in your first request, it looks for the keyword 30MM in the "text" field, and for the rest of the keywords in the default field.

In your example, I think that if you make the query as follows should work:

http://localhost:8080/products/select?indent=on&q=textfields:"30MM X 533MM Abrasives" AND text:"30MM X 533MM Abrasives"&fl=*,[docid]