ElasticSearch在生产环境中的行为不同

时间:2016-11-17 17:42:46

标签: ruby-on-rails ruby elasticsearch

我最近在我的应用程序中添加了一个新的搜索框。它适用于开发,但相同的功能不适用于暂存或生产环境。我错过了什么,拜托?

我正在使用Elasticsearch。我已经开始bundle exec rake users:index了。我还在开发和登台时比较了映射文件(elastic_search_mapping.json)。它们之间没有区别。

问题

开发和登台数据库是同步的。但是,相同的Elasticsearch查询在Staging上没有返回任何结果,而开发会得到一堆结果。

问题:只有在找到查询的完全匹配时,暂存环境才会返回结果。换句话说,它不允许模糊搜索。

恳求

有人能指出我未能做到的事吗?

   ## 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

1 个答案:

答案 0 :(得分:0)

来自您的评论:&#34;问题:只有在找到完全匹配的查询后,登台环境才会返回结果。换句话说,它不允许模糊搜索&#34;

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

两个群集上的

http://localhost:9200/_mapping。 (替换为正确的地址/端口)