我搜索“大括号”并希望返回3个结果(见帖子底部)。但是我只得到“大括号”是一个单独的关键字而不是关键字的一部分的结果。 我想指定一个权重,其中确切的单词具有最重要的权重,然后是较轻的权重,搜索字符串是另一个单词的一部分。
我试过了:
title_search_global:"brace"^100
title_search_global:*"brace"^100
title_search_global:"*brace*"^100
但这些都不起作用。
查询:
http://localhost:8983/solr/test/select/?indent=on&facet=true&wt=json&sort=clickcount%20desc&start=0&rows=9&fl=id,title&q=(title_search_global:(brace)%20OR%20title_search_global:%22brace%22^100))
返回:
{
"responseHeader":{
"status":0,
"QTime":1,
"params":{
"q":"(title_search_global:(brace) OR title_search_global:\"brace\"^100))",
"indent":"on",
"fl":"id,title",
"start":"0",
"sort":"clickcount desc",
"rows":"9",
"facet":"true",
"wt":"json"}},
"response":{"numFound":2,"start":0,"docs":[
{
"title":"feet brace",
"id":"3216741"},
{
"title":"Braun blood pressure scan",
"id":"3216742"}]
},
"facet_counts":{
"facet_queries":{},
"facet_fields":{},
"facet_dates":{},
"facet_ranges":{}}}
schema.xml中
<!-- for global search -->
<fieldType name="searchtext" class="solr.TextField" positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.EdgeNGramFilterFactory" minGramSize="3" maxGramSize="20" side="front" />
</analyzer>
<analyzer type="query">
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.EdgeNGramFilterFactory" minGramSize="3" maxGramSize="20" side="front" />
</analyzer>
</fieldType>
<fieldType name="exactmatch" class="solr.TextField" positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>
<field name="title" type="string" indexed="true" stored="true"/>
<field name="title_search_global" type="searchtext" indexed="true" stored="true"/>
<field name="exactmatch" type="exactmatch" indexed="true" stored="true"/>
<copyField source="title" dest="exactmatch"/>
<copyField source="title" dest="title_search_global"/>
我的产品名称是:
更新2
使用查询&q=title:(brace)&qf=title_search_global+exactmatch^1000&debugQuery=true
,我得到:
{
"responseHeader":{
"status":0,
"QTime":7,
"params":{
"indent":"on",
"fl":"id,title",
"start":"0",
"fq":"lang:\"nl\"",
"sort":"clickcount desc",
"rows":"9",
"q":"title:(brace)",
"qf":"title_search_global exactmatch^1000",
"facet.mincount":"1",
"facet":"true",
"wt":"json",
"facet.sort":"index",
"debugQuery":"true"}},
"response":{"numFound":3,"start":0,"docs":[
{
"title":"feet brace",
"id":"3216741"},
{
"title":"Braun blood pressure scan",
"id":"3216742"},
{
"title":"Super Ortho kneebrace",
"id":"3216743"}]
},
"facet_counts":{
"facet_queries":{},
"facet_fields":{},
"facet_dates":{},
"facet_ranges":{}},
"debug":{
"rawquerystring":"title:(brace)",
"querystring":"title:(brace)",
"parsedquery":"(+(DisjunctionMaxQuery(((title_search_global:tit title_search_global:itl title_search_global:tle title_search_global:le: title_search_global:titl title_search_global:itle title_search_global:tle: title_search_global:title title_search_global:itle: title_search_global:title:) | exactmatch:title:^1000.0)) DisjunctionMaxQuery(((title_search_global:bra title_search_global:rac title_search_global:ace title_search_global:brac title_search_global:race title_search_global:brace) | exactmatch:brace^1000.0))))/no_coord",
"parsedquery_toString":"+(((title_search_global:tit title_search_global:itl title_search_global:tle title_search_global:le: title_search_global:titl title_search_global:itle title_search_global:tle: title_search_global:title title_search_global:itle: title_search_global:title:) | exactmatch:title:^1000.0) ((title_search_global:bra title_search_global:rac title_search_global:ace title_search_global:brac title_search_global:race title_search_global:brace) | exactmatch:brace^1000.0))",
"explain":{
"3216741":"\n0.30617765 = (MATCH) product of:\n 0.6123553 = (MATCH) sum of:\n 0.6123553 = (MATCH) max of:\n 9.922679E-4 = (MATCH) sum of:\n 1.06803134E-4 = (MATCH) weight(title_search_global:bra in 0) [DefaultSimilarity], result of:\n 1.06803134E-4 = score(doc=0,freq=1.0 = termFreq=1.0\n), product of:\n 3.4177004E-4 = queryWeight, product of:\n 1.0 = idf(docFreq=3, maxDocs=4)\n 3.4177004E-4 = queryNorm\n 0.3125 = fieldWeight in 0, product of:\n 1.0 = tf(freq=1.0), with freq of:\n 1.0 = termFreq=1.0\n 1.0 = idf(docFreq=3, maxDocs=4)\n 0.3125 = fieldNorm(doc=0)\n 1.7709295E-4 = (MATCH) weight(title_search_global:rac in 0) [DefaultSimilarity], result of:\n 1.7709295E-4 = score(doc=0,freq=1.0 = termFreq=1.0\n), product of:\n 4.4009113E-4 = queryWeight, product of:\n 1.287682 = idf(docFreq=2, maxDocs=4)\n 3.4177004E-4 = queryNorm\n 0.40240064 = fieldWeight in 0, product of:\n 1.0 = tf(freq=1.0), with freq of:\n 1.0 = termFreq=1.0\n 1.287682 = idf(docFreq=2, maxDocs=4)\n 0.3125 = fieldNorm(doc=0)\n 1.7709295E-4 = (MATCH) weight(title_search_global:ace in 0) [DefaultSimilarity], result of:\n 1.7709295E-4 = score(doc=0,freq=1.0 = termFreq=1.0\n), product of:\n 4.4009113E-4 = queryWeight, product of:\n 1.287682 = idf(docFreq=2, maxDocs=4)\n 3.4177004E-4 = queryNorm\n 0.40240064 = fieldWeight in 0, product of:\n 1.0 = tf(freq=1.0), with freq of:\n 1.0 = termFreq=1.0\n 1.287682 = idf(docFreq=2, maxDocs=4)\n 0.3125 = fieldNorm(doc=0)\n 1.7709295E-4 = (MATCH) weight(title_search_global:brac in 0) [DefaultSimilarity], result of:\n 1.7709295E-4 = score(doc=0,freq=1.0 = termFreq=1.0\n), product of:\n 4.4009113E-4 = queryWeight, product of:\n 1.287682 = idf(docFreq=2, maxDocs=4)\n 3.4177004E-4 = queryNorm\n 0.40240064 = fieldWeight in 0, product of:\n 1.0 = tf(freq=1.0), with freq of:\n 1.0 = termFreq=1.0\n 1.287682 = idf(docFreq=2, maxDocs=4)\n 0.3125 = fieldNorm(doc=0)\n 1.7709295E-4 = (MATCH) weight(title_search_global:race in 0) [DefaultSimilarity], result of:\n 1.7709295E-4 = score(doc=0,freq=1.0 = termFreq=1.0\n), product of:\n 4.4009113E-4 = queryWeight, product of:\n 1.287682 = idf(docFreq=2, maxDocs=4)\n 3.4177004E-4 = queryNorm\n 0.40240064 = fieldWeight in 0, product of:\n 1.0 = tf(freq=1.0), with freq of:\n 1.0 = termFreq=1.0\n 1.287682 = idf(docFreq=2, maxDocs=4)\n 0.3125 = fieldNorm(doc=0)\n 1.7709295E-4 = (MATCH) weight(title_search_global:brace in 0) [DefaultSimilarity], result of:\n 1.7709295E-4 = score(doc=0,freq=1.0 = termFreq=1.0\n), product of:\n 4.4009113E-4 = queryWeight, product of:\n 1.287682 = idf(docFreq=2, maxDocs=4)\n 3.4177004E-4 = queryNorm\n 0.40240064 = fieldWeight in 0, product of:\n 1.0 = tf(freq=1.0), with freq of:\n 1.0 = termFreq=1.0\n 1.287682 = idf(docFreq=2, maxDocs=4)\n 0.3125 = fieldNorm(doc=0)\n 0.6123553 = (MATCH) weight(exactmatch:brace^1000.0 in 0) [DefaultSimilarity], result of:\n 0.6123553 = score(doc=0,freq=1.0 = termFreq=1.0\n), product of:\n 0.578667 = queryWeight, product of:\n 1000.0 = boost\n 1.6931472 = idf(docFreq=1, maxDocs=4)\n 3.4177004E-4 = queryNorm\n 1.058217 = fieldWeight in 0, product of:\n 1.0 = tf(freq=1.0), with freq of:\n 1.0 = termFreq=1.0\n 1.6931472 = idf(docFreq=1, maxDocs=4)\n 0.625 = fieldNorm(doc=0)\n 0.5 = coord(1/2)\n",
"3216742":"\n4.4501307E-6 = (MATCH) product of:\n 8.9002615E-6 = (MATCH) sum of:\n 8.9002615E-6 = (MATCH) max of:\n 8.9002615E-6 = (MATCH) product of:\n 5.3401567E-5 = (MATCH) sum of:\n 5.3401567E-5 = (MATCH) weight(title_search_global:bra in 1) [DefaultSimilarity], result of:\n 5.3401567E-5 = score(doc=1,freq=1.0 = termFreq=1.0\n), product of:\n 3.4177004E-4 = queryWeight, product of:\n 1.0 = idf(docFreq=3, maxDocs=4)\n 3.4177004E-4 = queryNorm\n 0.15625 = fieldWeight in 1, product of:\n 1.0 = tf(freq=1.0), with freq of:\n 1.0 = termFreq=1.0\n 1.0 = idf(docFreq=3, maxDocs=4)\n 0.15625 = fieldNorm(doc=1)\n 0.16666667 = coord(1/6)\n 0.5 = coord(1/2)\n",
"3216743":"\n2.4806696E-4 = (MATCH) product of:\n 4.9613393E-4 = (MATCH) sum of:\n 4.9613393E-4 = (MATCH) max of:\n 4.9613393E-4 = (MATCH) sum of:\n 5.3401567E-5 = (MATCH) weight(title_search_global:bra in 2) [DefaultSimilarity], result of:\n 5.3401567E-5 = score(doc=2,freq=1.0 = termFreq=1.0\n), product of:\n 3.4177004E-4 = queryWeight, product of:\n 1.0 = idf(docFreq=3, maxDocs=4)\n 3.4177004E-4 = queryNorm\n 0.15625 = fieldWeight in 2, product of:\n 1.0 = tf(freq=1.0), with freq of:\n 1.0 = termFreq=1.0\n 1.0 = idf(docFreq=3, maxDocs=4)\n 0.15625 = fieldNorm(doc=2)\n 8.8546476E-5 = (MATCH) weight(title_search_global:rac in 2) [DefaultSimilarity], result of:\n 8.8546476E-5 = score(doc=2,freq=1.0 = termFreq=1.0\n), product of:\n 4.4009113E-4 = queryWeight, product of:\n 1.287682 = idf(docFreq=2, maxDocs=4)\n 3.4177004E-4 = queryNorm\n 0.20120032 = fieldWeight in 2, product of:\n 1.0 = tf(freq=1.0), with freq of:\n 1.0 = termFreq=1.0\n 1.287682 = idf(docFreq=2, maxDocs=4)\n 0.15625 = fieldNorm(doc=2)\n 8.8546476E-5 = (MATCH) weight(title_search_global:ace in 2) [DefaultSimilarity], result of:\n 8.8546476E-5 = score(doc=2,freq=1.0 = termFreq=1.0\n), product of:\n 4.4009113E-4 = queryWeight, product of:\n 1.287682 = idf(docFreq=2, maxDocs=4)\n 3.4177004E-4 = queryNorm\n 0.20120032 = fieldWeight in 2, product of:\n 1.0 = tf(freq=1.0), with freq of:\n 1.0 = termFreq=1.0\n 1.287682 = idf(docFreq=2, maxDocs=4)\n 0.15625 = fieldNorm(doc=2)\n 8.8546476E-5 = (MATCH) weight(title_search_global:brac in 2) [DefaultSimilarity], result of:\n 8.8546476E-5 = score(doc=2,freq=1.0 = termFreq=1.0\n), product of:\n 4.4009113E-4 = queryWeight, product of:\n 1.287682 = idf(docFreq=2, maxDocs=4)\n 3.4177004E-4 = queryNorm\n 0.20120032 = fieldWeight in 2, product of:\n 1.0 = tf(freq=1.0), with freq of:\n 1.0 = termFreq=1.0\n 1.287682 = idf(docFreq=2, maxDocs=4)\n 0.15625 = fieldNorm(doc=2)\n 8.8546476E-5 = (MATCH) weight(title_search_global:race in 2) [DefaultSimilarity], result of:\n 8.8546476E-5 = score(doc=2,freq=1.0 = termFreq=1.0\n), product of:\n 4.4009113E-4 = queryWeight, product of:\n 1.287682 = idf(docFreq=2, maxDocs=4)\n 3.4177004E-4 = queryNorm\n 0.20120032 = fieldWeight in 2, product of:\n 1.0 = tf(freq=1.0), with freq of:\n 1.0 = termFreq=1.0\n 1.287682 = idf(docFreq=2, maxDocs=4)\n 0.15625 = fieldNorm(doc=2)\n 8.8546476E-5 = (MATCH) weight(title_search_global:brace in 2) [DefaultSimilarity], result of:\n 8.8546476E-5 = score(doc=2,freq=1.0 = termFreq=1.0\n), product of:\n 4.4009113E-4 = queryWeight, product of:\n 1.287682 = idf(docFreq=2, maxDocs=4)\n 3.4177004E-4 = queryNorm\n 0.20120032 = fieldWeight in 2, product of:\n 1.0 = tf(freq=1.0), with freq of:\n 1.0 = termFreq=1.0\n 1.287682 = idf(docFreq=2, maxDocs=4)\n 0.15625 = fieldNorm(doc=2)\n 0.5 = coord(1/2)\n"},
"QParser":"ExtendedDismaxQParser",
"altquerystring":null,
"boost_queries":null,
"parsed_boost_queries":[],
"boostfuncs":null,
"filter_queries":["lang:\"nl\""],
"parsed_filter_queries":["lang:nl"],
"timing":{
"time":7.0,
"prepare":{
"time":0.0,
"query":{
"time":0.0},
"facet":{
"time":0.0},
"mlt":{
"time":0.0},
"highlight":{
"time":0.0},
"stats":{
"time":0.0},
"debug":{
"time":0.0}},
"process":{
"time":7.0,
"query":{
"time":2.0},
"facet":{
"time":0.0},
"mlt":{
"time":0.0},
"highlight":{
"time":0.0},
"stats":{
"time":0.0},
"debug":{
"time":5.0}}}}}
答案 0 :(得分:1)
要获取所有“大括号”匹配项,请使用NGramFilterFactory
代替EdgeNGramFilterFactory
。
我不知道有任何直接提升完全匹配的方法,但是从this邮件列表帖子中获取,您可以创建一个只有简单标记的复制字段,并且应用大多数字分隔以获得确切的匹配言语,然后在该领域大力推进。
这看起来像是:
<fieldType name="exactmatch" class="solr.TextField" positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
<analyzer type="query">
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
<filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>
然后使用?q="brace"&qf=searchtext+exactmatch^1000