0

我正在尝试使用带有突出显示的轮胎(ElasticSearch),但我遇到了一些不一致的问题,我可能做错了什么。我遇到的问题是它并不总是突出我正在寻找的术语的所有格。这是设置:

索引:

indexes :thesis,              type: 'string',   boost:  2.0,            analyzer: 'snowball',  as: 'index_clean_thesis'
# the 'index_clean_thesis' removes some formatting characters as \t, \r, \n.

询问:

query { match :thesis, params[:text] } 

我正在查询“谷歌”这个词。

现在,我的 ElasticSearch 索引中有两个测试条目(一个包含我想要索引的条目之一的合法文本,而另一个包含一些我为测试目的而编造的文本)。在大文本中,我只得到了大约 14 个实际的“Google's”实例。在测试文本上,我得到了所有这些。

这是大文本中的一个实例,它没有突出显示“Google's”

Imminent changes to Google’s policies could dramatically lower the

这是大文本中唯一突出显示“Google's”的实例

I want to ask about Google's pending Toolbar change.

这是测试文本,其中突出显示按预期工作

Google's bla is blabla APPLE google is GOOGLE+ blabla facebook bla is yes yes no Google's ononononono tyeyeeyeyye ete pw iepq kw iqpe iwpq google pqiwop qoweo qpwoe qdpw adpw google's ksowoskwo google+

我还通过ElasticSearch 上的直接curl查询尝试了查询,但我得到了相同的行为。这是我尝试的curl查询:

curl -XGET http://localhost:9200/postings/_search -d '{
  "query": {
    "match": {
      "thesis": "Google"
    }
  },
  "highlight": {
    "fields": {
      "thesis": {
        "fragment_size": 40,
        "number_of_fragments": 300
      }
    }
  }
}'

请让我知道我做错了什么导致这种奇怪的行为。

4

1 回答 1

0

好吧,没关系,我刚刚意识到问题出在哪里 - 这有点荒谬,但我感谢 StackOverflow 代码文本编辑器哈哈:它让我意识到在它没有突出显示的示例中,实际上有一个不同的撇号和可能 ElasticSearch 并没有正确地阻止它。

抱歉这个愚蠢的帖子,但也许将来有人会发现它有用......我必须指定数据是从表单输入的,谁知道那个奇怪的撇号是如何进入的。我将在对象保存并放置正确的撇号。

这真的很难得到,因为我的文本编辑器似乎在这两个撇号之间没有显示出很大的区别......

谢谢,
弗拉德

于 2013-06-18T15:09:18.640 回答