簡體   English   中英

如何限制彈性搜索中命中的特定文檔的內容?

[英]How can limit the content of the particular document hit on elastic search?

{ "user": "dilbert", "postDate": "2011-12-12", "content": "Distribution is hard. Distribution should be easy." , "title": "On distributed search" }

現在,如果對該文檔進行搜索查詢。 我得到了全部內容。 可以說,如果內容很大,我只希望獲得點擊量的內容的特定部分。 什么是Api? 我在彈性搜索文檔中找不到它來限制大小或線條。

謝謝

您可以通過將size添加到根對象來限制結果集的大小(結果數),即

{
  "size": 5,
  "query": {
     ...
  }
}

並且,如果每個結果都太大,並且您只想獲取特定字段,則可以這樣做:

{
  "_source": {
    "include": [ "field1", "field2" ],
    "exclude": [ "field3" ]
  },
  "query": {
    ...
  "
}

好的,我是通過Highlight API獲得的。 您不能限制特定字段的內容大小或字符限制。

這樣,您只能獲得字符附近的字符,並且可以配置字符大小。

{ "query" : {...}, "highlight" : { "number_of_fragments" : 3, "fragment_size" : 150, "tag_schema" : "styled", "fields" : { } }

暫無
暫無

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

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