查询Solr时的奇怪行为

时间:2016-09-17 04:00:27

标签: solr lucene

我在Solr中设置了一个全新的代码,并没有更改任何默认设置。我将以下两个文件编入索引:

<add>
<doc>
<field name="id">weight loss</field>
<field name="text_en">weight loss</field>
</doc>
</add>

<add>
<doc>
<field name="id">weight loss2</field>
<field name="text_en">I strongly suspect that weight loss .</field>
</doc>
</add>

我执行一个简单的短语查询:

select?hl.fl=text_en&hl=on&indent=on&q="weight loss"&wt=json

我将两个文件都作为结果但没有突出显示!

  "response":{"numFound":2,"start":0,"docs":[
      {
        "id":"weight loss",
        "text_en":["weight loss"],
        "_version_":1545688757336801280},
      {
        "id":"weight loss2",
        "text_en":["I strongly suspect that weight loss ."],
        "_version_":1545688757344141312}]
  },
  "highlighting":{
    "weight loss":{},
    "weight loss2":{}}}

当我在前面提到的查询中添加参数 df = text_en 时,我会突出显示但只有一个结果!

  "response":{"numFound":1,"start":0,"docs":[
      {
        "id":"weight loss",
        "text_en":["weight loss"],
        "_version_":1545688757336801280}]
  },
  "highlighting":{
    "weight loss":{
      "text_en":["<em>weight loss</em>"]}}}

此外,当我添加 df = text_en 参数但删除短语词语中的引号时:

http://localhost:8983/solr/test2/select?df=text_en&hl.fl=text_en&hl=on&indent=on&q=weight loss&wt=json

我根本不明白这种行为。为什么我没有在第一种情况下突出显示?为什么单独匹配并且分别在第二和第三种情况下没有匹配?

1 个答案:

答案 0 :(得分:1)

text_en 的类型更改为text_general,这样您就可以开始突出显示所有情况。

__dirname