+ (%2B) 前缀代表必须包含
[root@h102 solr-5.3.0]# curl "http://localhost:8983/solr/gettingstarted/select?wt=json&indent=true&fl=id&rows=3&q=%2Bone+%2Bthree"
{
"responseHeader":{
"status":0,
"QTime":11,
"params":{
"fl":"id",
"indent":"true",
"q":"+one +three",
"wt":"json",
"rows":"3"}},
"response":{"numFound":20,"start":0,"maxScore":0.41965395,"docs":[
{
"id":"/data/solr/solr-5.3.0/docs/solr-core/org/apache/solr/schema/SimplePreAnalyzedParser.html"},
{
"id":"/data/solr/solr-5.3.0/docs/solr-core/org/apache/solr/util/doc-files/min-should-match.html"},
{
"id":"/data/solr/solr-5.3.0/docs/solr-core/org/apache/solr/handler/DumpRequestHandler.html"}]
}}
[root@h102 solr-5.3.0]#
By default, when you search for multiple terms and/or phrases in a single query, Solr will only require that one of them is present in order for a document to match. Documents containing more terms will be sorted higher in the results list. You can require that a term or phrase is present by prefixing it with a “+”; conversely, to disallow the presence of a term or phrase, prefix it with a “-“. To find documents that contain both terms “one” and “three”, enter +one +three in the q param in the core-specific Admin UI Query tab. Because the “+” character has a reserved purpose in URLs (encoding the space character), you must URL encode it for curl as “%2B”: To search for documents that contain the term “two” but don’t contain the term “one”, enter +two -one in the q param in the Admin UI. Again, URL encode “+” as “%2B”:
本文系转载,前往查看
如有侵权,请联系 cloudcommunity@tencent.com 删除。
本文系转载,前往查看
如有侵权,请联系 cloudcommunity@tencent.com 删除。