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

  • 相关阅读:
    今週のschedule
    软件架构师应该知道的97件事
    没办法的复习
    优秀程序员的45个习惯
    程序员如何追女孩
    那些相见恨晚的 JavaScript 技巧
    CodeSmith开发系列资料总结
    HR的至高机密:20个公司绝对不会告诉你的潜规则
    asp.net页面出错时的处理方法
    Asp.net 文件上传的 FileUpload FileName 和 FileUpload PostedFile.FileName的细节问题
  • 原文地址:https://www.cnblogs.com/qiu-hua/p/14196947.html
Copyright © 2011-2022 走看看