我肯定遗漏了一些东西,但是当我尝试使用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“只是为了确保这一点,尽管我认为没有必要突出显示。因此,我猜我在映射或查询规范中遗漏了一些东西,但我没有看到它。任何建议都将不胜感激。谢谢。
发布于 2012-08-11 02:52:41
在elasticsearch中,字段名称区分大小写。Title和title是两个不同的字段。尝试此查询:
curl -XPOST http://localhost:9200/myobject/_search\?pretty\=true -d '{
"query": {"query_string": {"query": "foobar"}},
"highlight": {"fields": {"title":{}}}
}https://stackoverflow.com/questions/11907555
复制相似问题