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

  • 相关阅读:
    .netcore返回HellowWorld四种方式(管道配置,管道扩展方法,中间件,IStartupFilter 使用中间件的升级扩展)
    Mysql分页大数据量查询优化
    swagger发布本地的调试的时候没事,发布服务器提示500 : {"Message":"出现错误。"}
    DBeaver的使用(impala和数据库)
    mysql远程连接问题
    java+thymeleaf-layout-dialect+thymeleaf的使用
    springboot+thyemeleaf+swagger项目的创建和问题的解决
    ffmpeg实践
    Camera.main
    python双曲线拟合
  • 原文地址:https://www.cnblogs.com/qiu-hua/p/14196947.html
Copyright © 2011-2022 走看看