zoukankan      html  css  js  c++  java
  • .添加索引和类型,同时设定edgengram分词和charsplit分词

    1.添加索引和类型,同时设定edgengram分词和charsplit分词

    curl -XPUT 'http://127.0.0.1:9200/userindex/' -d

    '{

      "settings": {

        "index": {

          "analysis": {

            "analyzer": {

              "charsplit": {

                "tokenizer": "my_ngram_tokenizer"

              },

              "edgengram": {

                "tokenizer": "my_edge_ngram_tokenizer"

              }

            },

            "tokenizer": {

              "my_ngram_tokenizer": {

                "token_chars": [

                  "letter",

                  "digit"

                ],

                "min_gram": "1",

                "type": "nGram",

                "max_gram": "1"

              },

              "my_edge_ngram_tokenizer": {

                "token_chars": [

                  "letter",

                  "digit"

                ],

                "min_gram": "2",

                "type": "edgeNGram",

                "max_gram": "5"

              }

            }

          },

          "number_of_shards": "5",

          "number_of_replicas": "1",

          "uuid": "gbT6I5puQH2LhzPJmv13fg",

          "version": {

            "created": "2010199"

          }

        }

      },

      "mappings": {

        "userinfo": {

          "properties": {

            "address": {

              "analyzer": "edgengram",

              "type": "string"

            },

            "address2": {

              "include_in_all": false,

              "analyzer": "charsplit",

              "type": "string"

            },

            "username": {

              "type": "string",

              "analyzer": "standard"

            }

          }

        }

      }

    }'

    2.添加一条记录

    curl -XPUT 'http://172.16.58.82:9200/userindex/userinfo/1/'

    '{

    "address": "good morning anting 靠近昆山",

    "address2": "anting你好 在安亭附近",

    "username": "james 你好"

    }

    '

    3.查询

    {

    "query": {

    "match_phrase_prefix": {

    "address": {

    "query": "good morn",

    "analyzer": "edgengram"

    }

    }

    }

    }

    查询见下图:

    clipboard

  • 相关阅读:
    1-接口测试基础知识
    import os
    好用封装好的函数
    python下载代码
    cookie关系图,url编码(urllib.parse模块)
    import flask(make_response),urllib,requests,base64
    mock接口开发,excel(读,写,修改)
    import json,random,time,datetime,hashlib,redis,pymysql
    集合和函数
    python 文件读写
  • 原文地址:https://www.cnblogs.com/thaughtZhao/p/5780102.html
Copyright © 2011-2022 走看看