gpt4 book ai didi

elasticsearch - ElasticSearch完成建议程序-不返回数据

转载 作者:行者123 更新时间:2023-12-02 22:29:44 25 4
gpt4 key购买 nike

您能用ElasticSearch建议我吗?
https://www.elastic.co/guide/en/elasticsearch/reference/5.1/search-suggesters-completion.html

  • 我已经在ES索引
  • 中创建了类型

    curl -XPUT'本地主机:9200 / tass_suggest_test / _mapping / company?pretty'-H'内容类型:application / json'-d'
    {
    "company": {
    "properties": {
    "id": {
    "type": "integer"
    },
    "inn": {
    "type": "keyword"
    },
    "innSuggest" : {
    "type" : "completion"
    }
    }
    }
    }
    '

    用一些数据填充它
  • 现在我尝试获取数据

  • curl -XGET' http://localhost:9200/tass_suggest_test/company/_search?pretty'-d'
    {
    "from" : 0, "size" : 1,
    "query" : {
    "wildcard" : { "inn" : "78200*" }
    }
    }'

    没关系,我有一些数据:
    {
    "took" : 1,
    "timed_out" : false,
    "_shards" : {
    "total" : 10,
    "successful" : 10,
    "failed" : 0
    },
    "hits" : {
    "total" : 1,
    "max_score" : 1.0,
    "hits" : [
    {
    "_index" : "tass_suggest_test",
    "_type" : "company",
    "_id" : "23515589",
    "_score" : 1.0,
    "_source" : {
    "id" : 23515589,
    "inn" : "7820056885",
    "innSuggest" : "7820056885"
    }
    }
    ]
    }
    }

    但是当我尝试建议查询时,我什么也没得到
    curl -XGET 'localhost:9200/tass_suggest_test/_suggest?pretty' -H 'Content-Type: application/json' -d'
    {
    "company-suggest" : {
    "prefix" : "78200",
    "completion" : {
    "field" : "innSuggest"
    }
    }
    }
    '

    {
    "_shards" : {
    "total" : 10,
    "successful" : 10,
    "failed" : 0
    },
    "company-suggest" : [
    {
    "text" : "7820056885",
    "offset" : 0,
    "length" : 10,
    "options" : [ ]
    }
    ]
    }

    我的错在哪里

    最佳答案

    默认情况下,完成建议程序使用简单分析器,因此从输入字段中删除了数字。如果要保留数字,可以使用建议字段的空白分析器:

    {
    "company": {
    "properties": {
    "id": {
    "type": "integer"
    },
    "inn": {
    "type": "keyword"
    },
    "innSuggest" : {
    "type" : "completion",
    "analyzer": "whitespace"
    }
    }
    }
    }

    关于elasticsearch - ElasticSearch完成建议程序-不返回数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45998769/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com