我最近在我的应用程序中添加了一个新的搜索框。它可以在开发中使用,但是相同的功能在暂存或生产环境中不起作用。请问我错过了什么?
我正在使用Elasticsearch。我已经运行了bundle exec rake users:index
。我还比较了开发和暂存中的映射文件(elastic_search_mapping.json)。它们之间没有区别。
问题
开发和登台数据库是同步的。但是,相同的Elasticsearch查询在“登台”上不返回任何结果,而开发则获得了很多结果。
陷阱:仅当找到查询的完全匹配项时,登台环境才返回结果。换句话说,它不允许进行模糊搜索。
恳求
谁能指出我做不到的事情吗?
## 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
这是我在登台上运行相同结果时得到的结果。它不返回任何结果。
## 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。 (替换为正确的地址/端口)
关于ruby-on-rails - ElasticSearch在生产环境中的行为有所不同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40661632/