Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/visual-studio/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
<img src="//i.stack.imgur.com/RUiNP.png" height="16" width="18" alt="" class="sponsor tag img">elasticsearch 按令牌计数使用筛选器进行搜索_<img Src="//i.stack.imgur.com/RUiNP.png" Height="16" Width="18" Alt="" Class="sponsor Tag Img">elasticsearch_Token - Fatal编程技术网 elasticsearch 按令牌计数使用筛选器进行搜索,elasticsearch,token,elasticsearch,Token" /> elasticsearch 按令牌计数使用筛选器进行搜索,elasticsearch,token,elasticsearch,Token" />

elasticsearch 按令牌计数使用筛选器进行搜索

elasticsearch 按令牌计数使用筛选器进行搜索,elasticsearch,token,elasticsearch,Token,分析文档中的字段,以创建令牌 {“message”:“hello world”}->令牌:[“hello”,“world”] {“message”:“hello”}->令牌:[“hello”] {“消息”:“世界”}->令牌:[“世界”] {“message”:“hello java”}->令牌:[“hello”,“java”] {“message”:“java”}->令牌:[“java”] 是否可以搜索特定字段中包含给定标记和1个或多个其他标记的所有文档 令牌“hello”的给定示例的结果为

分析文档中的字段,以创建令牌

  • {“message”:“hello world”}
    ->令牌:[“hello”,“world”]
  • {“message”:“hello”}
    ->令牌:[“hello”]
  • {“消息”:“世界”}
    ->令牌:[“世界”]
  • {“message”:“hello java”}
    ->令牌:[“hello”,“java”]
  • {“message”:“java”}
    ->令牌:[“java”]
  • 是否可以搜索特定字段中包含给定标记和1个或多个其他标记的所有文档

    • 令牌“hello”的给定示例的结果为:
      • 1,4
    • 对于“世界”:
      • 一,
    如中所述,可以访问令牌或有关令牌的统计信息。这仅适用于特定文档,但不适用于查询或聚合的搜索筛选器。
    如果有人能帮忙,那就太好了。

    是的,你可以用这个类型。例如,在映射中,可以将
    message
    定义为多字段,以包含消息本身(即“hello”、“hello world”等)以及消息的令牌数。然后,您将能够在查询中包含对字数的约束

    因此,
    消息
    的映射应如下所示:

    curl -XPUT localhost:9200/tests -d '
    {
      "mappings": {
        "test": {
          "properties": {
            "message": {
              "type": "string",           <--- message is a normal analyzed string
              "fields": {
                "word_count": {           <--- a sub-field to include the word count
                  "type": "token_count",
                  "store": "yes",
                  "analyzer": "standard"
                }
              }
            }
          }
        }
      }
    }
    
    类似地,如果在上述查询中将
    hello
    替换为
    world
    ,则只会得到
    hello world

    curl -XPOST localhost:9200/tests/test/_search -d '
    {
      "query": {
        "bool": {
          "must": [
            {
              "match": {
                "message": "hello"
              }
            },
            {
              "range": {
                "message.word_count": {
                  "gt": 1
                }
              }
            }
          ]
        }
      }
    }