[英]Use termfreq(field,term) function for phrase with space in SOLR 4.1
[英]How does termFreq function query work in Apache Solr
我正在嘗試使用其 API 查詢 solr 索引,
http://localhost:8983/solr/documents/select?defType=func&q=termfreq(contents,'hello)&wt=json
我已經索引了 3 個文檔,並且 2 個文檔/記錄具有術語“你好”,但它返回所有文檔。
{
"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 及其在這些文檔中出現的文檔。
我是正確的還是我沒有正確理解這個功能?
你不能在 Solr 中使用這樣的函數。 要僅檢索包含術語hello
文檔,並將計數作為分數,請使用:
q=content:hello _val_:"termfreq(contents,'hello')"
查詢的第一部分將結果集限制為content
字段中包含hello
的文檔,而第二部分通過魔術_val_
字段調用函數查詢解析器。 該函數的結果被指定為文檔的分數,有效地返回匹配的文檔和這些文檔中給定術語的計數。
如果您不想將fl=termfreq(contents,'hello'),score,foo
指定為fl=termfreq(contents,'hello'),score,foo
您還應該能夠直接在您的字段列表中使用termfreq(contents, 'hello')
( fl=termfreq(contents,'hello'),score,foo
)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.