簡體   English   中英

Elasticsearch熒光筆標記的數量

[英]Elasticsearch highlighter number of tokens before and after

我正在使用普通熒光筆(Elasticsearch 5.2)。 這是一個例子

PUT bookstore
{
  "mappings": {
    "books": {
      "properties": {
        "list": {
          "properties": {
            "summary": {
              "type": "text"
            },
            "title": {
              "type": "text"
            }
          }
        }
      }
    }
  }
}

POST bookstore/books/1
{
  "list": [
    {
      "summary": "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",
      "title": "Elasticsearch"
    }
  ]
}

GET bookstore/books/_search
{
  "query": {
    "simple_query_string": {
      "query": "scrambled"
    }
  },
  "highlight": {
    "fields": {
      "*": {
        "require_field_match": false,
        "number_of_fragments": 1,
        "fragment_size": 70
      }
    }
  }
}

"highlight": {
  "list.summary": [
    " <em>scrambled</em> it to make a type specimen book. It has survived not only five"
  ]
}

我的問題是,如何使突出顯示的單詞居中? 在這種情況下,突出顯示的單詞在開頭,在其他情況下在結尾。 我如何確保它在中間?

理想情況下,我要指定突出顯示的文本前后的標記數量,而不是片段大小。

最后,不支持此功能。 解決方法是設置number_of_fragments:0 這將返回帶有突出顯示的完整字段。 此后,很容易在應用程序級別上應用任何自定義邏輯。

http://elasticsearch-users.115913.n3.nabble.com/Controlling-highlight-fragments-td1563243.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM