问题
I have a column named title. I want to search this column. There is no problem when I use single word like title:'sport'
OR title:"sport"
. Both giving same number of record.
My problem is when I search with 2 or more words without double quotes(with double quotes giving exact result ex: title:"sport education"
).
title:'sport education'
- returning irrelevant records(more title's don't have sport or education word)
+title:'sport education'
- returns the same number of record for the search oftitle:'sport' / title:"sport"
.
what should I do to get atleast any one search word must match in the column?
Note: Solr version 6.3.0
Thank you in advance!
回答1:
I bet what you are looking for is the following chain of parameters:
http://$solr_host:8983/solr/magazines/select&q=sport+education&df=title&q.op=OR
Let me decipher it for you:
- q=sport+education. You are free to use query in such free form.
- df=title. Here you are specifying default field for search.
- q.op=OR (which is default, feel free to omit it).
$q
will be tokenized according to$df
fieldType and the clauses will be joined via OR like this:title:sport OR title:education
For more information you can follow Common Query Parameters or Local Parameters in Queries.
回答2:
After parsing your query title:'sport education'
will look like this
title:sport
text:education
single quote doesn't work as double quotes.
so term education
is searched in default field df
(text, check it in solr-config file)
In schema file you might have copied many other field into text using copyfield
so you get other documents(fields which have education in it)
You should specify field name to search different term in different field liketitle:sport name:sachin
.
In phrase query using double quotes title:"sport education"
this gives you all documents with title field having sport education
in it.
来源:https://stackoverflow.com/questions/41156631/select-query-for-search-with-2-or-more-words-without-double-quotes-in-solr