ElasticSearch在生产环境中的表现是不同的



我最近在我的应用程序中添加了一个新的搜索框。它可以在开发环境中工作,但是同样的特性不能在登台或生产环境中工作。请问我错过了什么?

我正在使用Elasticsearch。我已经运行了bundle exec rake users:index。我还比较了开发和staging上的映射文件(elastic_search_mapping.json)。他们之间没有区别。

开发数据库和登台数据库是同步的。然而,同样的Elasticsearch查询在Staging上没有返回结果,而开发得到了一堆结果。

Gotcha:登台环境只有在找到查询的精确匹配时才返回结果。换句话说,它不允许模糊搜索。<<h2>请求/h2>谁能指出我做错了什么吗?

   ## On Development
    ⤷  curl -v http://localhost:9200/red_development/users/_count?pretty -d '{
      "query": {
        "match": {
          "registered_name": "SBN"
        }
      }
    }'
    *   Trying 127.0.0.1...
    * Connected to localhost (127.0.0.1) port 9200 (#0)
    > POST /red_development/users/_count?pretty HTTP/1.1
    > Host: localhost:9200
    > User-Agent: curl/7.49.1
    > Accept: */*
    > Content-Length: 72
    > Content-Type: application/x-www-form-urlencoded
    >
    * upload completely sent off: 72 out of 72 bytes
    < HTTP/1.1 200 OK
    < Content-Type: application/json; charset=UTF-8
    < Content-Length: 95
    <
    {
      "count" : 3,
      "_shards" : {
        "total" : 5,
        "successful" : 5,
        "failed" : 0
      }
    }
    * Connection #0 to host localhost left intact

这是我在Staging上运行相同结果得到的结果。它不返回任何结果。

    ## on Staging
    ⤷  curl -v https://xxxxx:xxxxx@foofoo5625275.eu-west-1.bonsai.io/red_production/users/_count?pretty -d '{
    >   "query": {
    >     "match": {
    >       "registered_name": "SBN"
    >     }
    >   }
    > }'
    *   Trying xx.yy.zzz.aaa...
    * Connected to foofoo5625275.eu-west-1.bonsai.io (xx.yy.zzz.aaa) port 443 (#0)
    * TLS 1.2 connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
    * Server certificate: eu-west-1.bonsai.io
    * Server certificate: Amazon
    * Server certificate: Amazon Root CA 1
    * Server certificate: Starfield Services Root Certificate Authority - G2
    * Server auth using Basic with user 'xxxxxx'
    > POST /red_production/users/_count?pretty HTTP/1.1
    > Host: foofoo5625275.eu-west-1.bonsai.io
    > Authorization: Basic aDA2czQ0Zm1ycQ==
    > User-Agent: curl/7.49.1
    > Accept: */*
    > Content-Length: 72
    > Content-Type: application/x-www-form-urlencoded
    >
    * upload completely sent off: 72 out of 72 bytes
    < HTTP/1.1 200 OK
    < Content-Type: application/json; charset=UTF-8
    < Server: Nespr 1.1
    < X-Bonsai-Backend: xx.yy.zzz.aaa
    < X-Queue-Duration: 0
    < X-Request-Duration: 3
    < X-Request-Id: 0922c231-44d8-4720-b3b1-df113bb8434f
    < Content-Length: 95
    < Connection: keep-alive
    <
    {
      "count" : 0,
      "_shards" : {
        "total" : 1,
        "successful" : 1,
        "failed" : 0
      }
    }
    * Connection #0 to host foofoo5625275.eu-west-1.bonsai.io left intact

来自您的评论:"Gotcha:登台环境只有在找到查询的精确匹配时才返回结果。换句话说,它不允许模糊搜索"

"

在我看来,你的运行时映射可能是不同的;比较:

http://localhost:9200/_mapping在两个集群上。(用正确的地址/端口替换)

相关内容

最新更新