zoukankan      html  css  js  c++  java
  • ES基础(二十七)自动补全与基于上下文的提示

     

     

     

     

     

     

     

    课程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 comments
    PUT comments
    PUT comments/_mapping
    {
      "properties": {
        "comment_autocomplete":{
          "type": "completion",
          "contexts":[{
            "type":"category",
            "name":"comment_category"
          }]
        }
      }
    }
    
    POST comments/_doc
    {
      "comment":"I love the star war movies",
      "comment_autocomplete":{
        "input":["star wars"],
        "contexts":{
          "comment_category":"movies"
        }
      }
    }
    
    POST comments/_doc
    {
      "comment":"Where can I find a Starbucks",
      "comment_autocomplete":{
        "input":["starbucks"],
        "contexts":{
          "comment_category":"coffee"
        }
      }
    }
    
    
    POST comments/_search
    {
      "suggest": {
        "MY_SUGGESTION": {
          "prefix": "sta",
          "completion":{
            "field":"comment_autocomplete",
            "contexts":{
              "comment_category":"coffee"
            }
          }
        }
      }
    }

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

  • 相关阅读:
    CSS选择符详解之关系选择符篇
    linux基础命令入门
    asp.net 大数据导出execl实现分开压缩并下载
    一个页面从输入 URL 到页面加载显示完成,这个过程中都发生了什么?
    Git学习笔记
    ssalesforce IoT
    根据生日自动计算年龄
    Salesforce简单练习案例
    JavaScript对象
    JavaScript函数
  • 原文地址:https://www.cnblogs.com/qiu-hua/p/14196959.html
Copyright © 2011-2022 走看看