elasticsearch 根据字段中的单词返回文档数';s弦,elasticsearch,kibana,elasticsearch,Kibana" /> elasticsearch 根据字段中的单词返回文档数';s弦,elasticsearch,kibana,elasticsearch,Kibana" />

elasticsearch 根据字段中的单词返回文档数';s弦

elasticsearch 根据字段中的单词返回文档数';s弦,elasticsearch,kibana,elasticsearch,Kibana,如何返回“单词”列表中包含2个以上元素且“单词组合”中包含3个以上单词的文档数。 有没有办法计算字符串中的字数 示例:如果(单词长度“>2)和(“单词.单词组合”超过3个单词),则返回文档 我储存了许多文件。一个文档的结构如下所示: "_source" : { "group_words" : [ { "amount" : 1140, "words" : [ { "relevance_score" : 56, "points" :

如何返回“单词”列表中包含2个以上元素且“单词组合”中包含3个以上单词的文档数。 有没有办法计算字符串中的字数

示例:如果(单词长度“>2)和(“单词.单词组合”超过3个单词),则返回文档

我储存了许多文件。一个文档的结构如下所示:

"_source" : {
"group_words" : [

  {
    "amount" : 1140,
    "words" : [
      {
        "relevance_score" : 56,
        "points" : 66461,
        "bits" : 100,
        "word_combination" : "cat dog"
      },
      {
        "relevance_score" : 84,
        "points" : 45202,
        "bits" : 990,
        "word_combination" : "cat dog elephant"
      },
      {
        "relevance_score" : 99,
        "points" : 30974,
        "bits" : 70,
        "word_combination" : "elephant cat mouse leopard"
      }
    ],
    "group" : "whatever"
  },
  {
    "amount" : 1320,
    "words" : [
      {
        "relevance_score" : 25,
        "points" : 53396,
        "bits" : 70,
        "word_combination" : "lion elephant"
      },
      {
        "relevance_score" : 66,
        "points" : 52166,
        "bits" : 20,
        "word_combination" : "lion mouse fish cat dog"
      },
      {
        "relevance_score" : 82,
        "points" : 49316,
        "bits" : 810,
        "word_combination" : "elephant cat mouse leopard dog lion"
      },
      {
        "relevance_score" : 87,
        "points" : 127705,
        "bits" : 290,
        "word_combination" : "elephant cat mouse leopard tiger lion"
      }
    ],
    "group" : "whatever"
  },
  {
    "amount" : 11260,
    "words" : [
      {
        "relevance_score" : 0,
        "points" : 37909,
        "bits" : 9000,
        "word_combination" : "elephant cat mouse leopard tiger lion monkey"
      },
      {
        "relevance_score" : 3,
        "points" : 35782,
        "bits" : 540,
        "word_combination" : "elephant"
      }
    ],
    "group" : "whatever"
  }      
]
...
"word_combination": {
  "type": "text",
  "fields": {
    "count": {
      "type": "token_count",
      "analyzer": "standard"
    }
  }
}

}

关于
单词
数组中的元素数量,我的建议是在索引时将该数字存储在另一个字段
单词计数

  {
    "amount" : 1140,
    "words_count": 3,                           <--- add this
    "words" : [
      {
        "relevance_score" : 56,
        "points" : 66461,
        "bits" : 100,
        "word_combination" : "cat dog"
      },
      {
        "relevance_score" : 84,
        "points" : 45202,
        "bits" : 990,
        "word_combination" : "cat dog elephant"
      },
      {
        "relevance_score" : 99,
        "points" : 30974,
        "bits" : 70,
        "word_combination" : "elephant cat mouse leopard"
      }
    ],
    "group" : "whatever"
  },

然后在查询中,您可以访问
word\u composition.count
,它将包含
word\u composition
字段中出现的令牌数(由指定的分析器分析)。

谢谢您的回答。但是,是否有一种方法可以在不添加额外单词\u count字段的情况下执行此操作?