Search termFreq函数查询在ApacheSolr中是如何工作的
我正在尝试使用其API查询solr索引Search termFreq函数查询在ApacheSolr中是如何工作的,search,solr,full-text-search,full-text-indexing,Search,Solr,Full Text Search,Full Text Indexing,我正在尝试使用其API查询solr索引 http://localhost:8983/solr/documents/select?defType=func&q=termfreq(contents,'hello)&wt=json 我为3个文档编制了索引,2个文档/记录有术语“hello”,但它会返回所有文档 { "responseHeader":{ "status":0, "QTime":0, "params":{ "q":"termfreq(contents
http://localhost:8983/solr/documents/select?defType=func&q=termfreq(contents,'hello)&wt=json
我为3个文档编制了索引,2个文档/记录有术语“hello”,但它会返回所有文档
{
"responseHeader":{
"status":0,
"QTime":0,
"params":{
"q":"termfreq(contents,'hello')",
"defType":"func",
"indent":"on",
"wt":["json",
"json"],
"_":"1538568705504"}},
"response":{"numFound":3,"start":0,"docs":[
{*here I have docs*}
]
}
我只希望文档中包含单词hello及其在这些文档中的出现
{
"responseHeader":{
"status":0,
"QTime":0,
"params":{
"q":"termfreq(contents,'hello')",
"defType":"func",
"indent":"on",
"wt":["json",
"json"],
"_":"1538568705504"}},
"response":{"numFound":3,"start":0,"docs":[
{*here I have docs*}
]
}
我是正确的还是没有正确理解这个函数?在Solr中不能使用这样的函数。要仅检索存在术语
hello
的文档,并将计数作为分数,请使用:
q=content:hello _val_:"termfreq(contents,'hello')"
查询的第一部分将结果集限制为在content
字段中包含hello
的文档,而第二部分通过magic\u val
字段。该函数的结果被指定为文档的分数,有效地返回匹配的文档和这些文档中给定术语的计数
{
"responseHeader":{
"status":0,
"QTime":0,
"params":{
"q":"termfreq(contents,'hello')",
"defType":"func",
"indent":"on",
"wt":["json",
"json"],
"_":"1538568705504"}},
"response":{"numFound":3,"start":0,"docs":[
{*here I have docs*}
]
}
如果您不想将其指定为分数,您还应该能够在字段列表中直接使用
termfreq(contents,'hello')
(fl=termfreq(contents,'hello')、score,foo
),您不能在Solr中使用类似的函数。要仅检索存在术语hello
的文档,并将计数作为分数,请使用:
q=content:hello _val_:"termfreq(contents,'hello')"
查询的第一部分将结果集限制为在content
字段中包含hello
的文档,而第二部分通过magic\u val
字段。该函数的结果被指定为文档的分数,有效地返回匹配的文档和这些文档中给定术语的计数
{
"responseHeader":{
"status":0,
"QTime":0,
"params":{
"q":"termfreq(contents,'hello')",
"defType":"func",
"indent":"on",
"wt":["json",
"json"],
"_":"1538568705504"}},
"response":{"numFound":3,"start":0,"docs":[
{*here I have docs*}
]
}
您还应该能够在字段列表中直接使用
termfreq(contents,'hello')
(fl=termfreq(contents,'hello')、score、foo
)如果你不想把它作为分数。这个\u val\u
的东西是有道理的,但是如果我得到的两个文档都有hello或not加上termfreq
的话,q
的目的是什么呢。但我的问题是得到分数还是计数?有什么办法可以算数吗?分数就是总数。使用\u val\u
语法时,函数返回的值被指定为分数字段,因此,如果使用文档返回的分数
值,则这将是术语出现的次数。q
中的另一个术语的目的是将文档集限制为包含hello
的文档集(即termfreq大于0的文档)。是否有任何方法返回此查询中的分数
returnq=content:hello\u val:“termfreq(contents,'hello')”
?如果您想执行定期评分的查询,但将termfreq作为单独的字段附加,您可以使用我提到的第二种语法-使用函数字段列表将其作为字段(fl=termfreq(contents,'hello')
)。http://localhost:8983/solr/collection/select?fl=termfreq(目录,你好)&q=*:*
正常工作。您还可以使用字段别名来获取更友好名称下的值,fl=hello\u freq:termfreq(contents,hello)&q=*:*
。\u val\u
这件事是有道理的,但是如果我得到的两个文档都有hello或not加上termfreq
的话,那么q
的目的是什么呢。但我的问题是得到分数还是计数?有什么办法可以算数吗?分数就是总数。使用\u val\u
语法时,函数返回的值被指定为分数字段,因此,如果使用文档返回的分数
值,则这将是术语出现的次数。q
中的另一个术语的目的是将文档集限制为包含hello
的文档集(即termfreq大于0的文档)。是否有任何方法返回此查询中的分数
returnq=content:hello\u val:“termfreq(contents,'hello')”
?如果您想执行定期评分的查询,但将termfreq作为单独的字段附加,您可以使用我提到的第二种语法-使用函数字段列表将其作为字段(fl=termfreq(contents,'hello')
)。http://localhost:8983/solr/collection/select?fl=termfreq(目录,你好)&q=*:*
正常工作。您还可以使用字段别名来获取更友好名称下的值,fl=hello\u freq:termfreq(contents,hello)&q=*:*
。