Question

I am now using solr to query .I want to find all the documents whose key "title" contains text "Bifidobacterium bifidum" or key "abstract" contains text "Bifidobacterium bifidum".So , I write my query like below:

String queryCondition = "title:*Bifidobacterium bifidum* OR  abstract:*Bifidobacterium bifidum*";

From the result ,I find out that the returned result is not what I want ,documents whose title contains "Bifidobacterium" or "bifidum" , or whose title contains "Bifidobacterium" or "bifidum" are all returned . So , my question is ,how should I write my query to satisfy my query need?

Était-ce utile?

La solution

The * is special symbol, a wildcard. Similar to regular expressions, it tells Solr to match everything. So querying for bifidum* would return everything that starts with bifidum. Not what you want, right?

When reading about Solr's query syntax in the manual, you will find a section named Specifying Terms for the Standard Query Parser there is written

A phrase is a group of words surrounded by double quotes such as "hello dolly"

This is what you need ...

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top