Elasticsearch with Tire,突出显示无法正常工作

时间:2012-08-10 18:49:52

标签: highlighting elasticsearch tire

我必须在这里遗漏一些东西,但是当我试图在Elasticsearch的搜索中突出显示时,我根本没有看到任何突出显示,但也没有错误。我不认为这是一个轮胎问题,但我提到了轮胎以防它重要。使用Tire进行索引非常简单(为简洁起见,将一些字段取出):

mapping :_source => { :excludes => ['attachment'] } do
  indexes :id, :type => 'integer'
  indexes :title, :store => true
  indexes :attachment, :type => 'attachment', :_source => { :enabled => false }
end

使用curl,我可以尝试这个查询,它工作正常,但结果中没有突出显示:

curl -XPOST http://localhost:9200/myobject/_search\?pretty\=true -d '{             
  "query": {"query_string": {"query": "foobar"}},
  "highlight": {"fields": {"Title":{}}}
}'

请注意,我在映射中添加了“:store => true”以确保,但我不认为有必要使突出显示工作。所以我猜我在映射或查询规范中缺少某些东西,但我没有看到它。任何建议将非常感谢。感谢。

1 个答案:

答案 0 :(得分:2)

字段名称在elasticsearch中区分大小写。 Titletitle是两个不同的字段。试试这个问题:

curl -XPOST http://localhost:9200/myobject/_search\?pretty\=true -d '{             
  "query": {"query_string": {"query": "foobar"}},
  "highlight": {"fields": {"title":{}}}
}
相关问题