zoukankan      html  css  js  c++  java
  • ES基础(二十六)Term & Phrase Suggester

     

     

     

     

    课程Demo

    DELETE articles
    PUT articles
    {
      "mappings": {
        "properties": {
          "title_completion":{
            "type": "completion"
          }
        }
      }
    }
    
    POST articles/_bulk
    { "index" : { } }
    { "title_completion": "lucene is very cool"}
    { "index" : { } }
    { "title_completion": "Elasticsearch builds on top of lucene"}
    { "index" : { } }
    { "title_completion": "Elasticsearch rocks"}
    { "index" : { } }
    { "title_completion": "elastic is the company behind ELK stack"}
    { "index" : { } }
    { "title_completion": "Elk stack rocks"}
    { "index" : {} }
    
    
    POST articles/_search?pretty
    {
      "size": 0,
      "suggest": {
        "article-suggester": {
          "prefix": "elk ",
          "completion": {
            "field": "title_completion"
          }
        }
      }
    }
    
    DELETE articles
    
    POST articles/_bulk
    { "index" : { } }
    { "body": "lucene is very cool"}
    { "index" : { } }
    { "body": "Elasticsearch builds on top of lucene"}
    { "index" : { } }
    { "body": "Elasticsearch rocks"}
    { "index" : { } }
    { "body": "elastic is the company behind ELK stack"}
    { "index" : { } }
    { "body": "Elk stack rocks"}
    { "index" : {} }
    {  "body": "elasticsearch is rock solid"}
    
    
    POST _analyze
    {
      "analyzer": "standard",
      "text": ["Elk stack  rocks rock"]
    }
    
    POST /articles/_search
    {
      "size": 1,
      "query": {
        "match": {
          "body": "lucen rock"
        }
      },
      "suggest": {
        "term-suggestion": {
          "text": "lucen rock",
          "term": {
            "suggest_mode": "missing",
            "field": "body"
          }
        }
      }
    }
    
    
    POST /articles/_search
    {
    
      "suggest": {
        "term-suggestion": {
          "text": "lucen rock",
          "term": {
            "suggest_mode": "popular",
            "field": "body"
          }
        }
      }
    }
    
    
    POST /articles/_search
    {
    
      "suggest": {
        "term-suggestion": {
          "text": "lucen rock",
          "term": {
            "suggest_mode": "always",
            "field": "body",
          }
        }
      }
    }
    
    
    POST /articles/_search
    {
    
      "suggest": {
        "term-suggestion": {
          "text": "lucen hocks",
          "term": {
            "suggest_mode": "always",
            "field": "body",
            "prefix_length":0,
            "sort": "frequency"
          }
        }
      }
    }
    
    
    POST /articles/_search
    {
      "suggest": {
        "my-suggestion": {
          "text": "lucne and elasticsear rock hello world ",
          "phrase": {
            "field": "body",
            "max_errors":2,
            "confidence":0,
            "direct_generator":[{
              "field":"body",
              "suggest_mode":"always"
            }],
            "highlight": {
              "pre_tag": "<em>",
              "post_tag": "</em>"
            }
          }
        }
      }
    }

    本文来自博客园,作者:秋华,转载请注明原文链接:https://www.cnblogs.com/qiu-hua/p/14196947.html

  • 相关阅读:
    链路追踪
    Zuul网关
    MyBatis批量插入
    自定义组件使用v-model
    正则表达式入门
    博客园主题1【备份】
    关于我
    input输入框内容规范正则总结
    实例003:完全平方数
    python基础day5dict
  • 原文地址:https://www.cnblogs.com/qiu-hua/p/14196947.html
Copyright © 2011-2022 走看看