SOLR在multiValue字段中返回一个值

时间:2018-10-10 11:55:33

标签: solr solrj multivalue

我是SOLR的新手,我对多值字段有疑问。

我的文档具有以下格式:

{
"question":[
   "question 1",
   "question 2".
   "question 3"
   "question 4"
],

"answer": "Here is the answer"
}

当我搜索查询:“ question:question 2”时,SOLR将保留文档返回为:

{"question":[
   "question 1",
   "question 2".
   "question 3"
   "question 4"
],

"answer": "Here is the answer"}

有什么方法可以使结果仅包含“多值”字段的“最佳”值:

{
"question":[
   "question 2".
],

"answer": "Here is the answer"
}

谢谢。

2 个答案:

答案 0 :(得分:1)

也许您可以使用“突出显示”来查找找到文档的原因。 https://lucene.apache.org/solr/guide/6_6/highlighting.html

答案 1 :(得分:0)

如果以下方法不能解决您的问题,请共享您的架构文件。 将question的字段类型设为

<fieldType class="org.apache.solr.schema.TextField" name="SetOfTextField">
<analyzer>
<tokenizer class="solr.StandardTokenizerFactory"/>
</analyzer>
</fieldType>

并以question:"question 2"

触发查询
相关问题