如何使用Nginx代理Elasticsearch查询

时间:2019-07-08 14:11:52

标签: elasticsearch nginx

我想用Nginx将复杂的Elasticsearch查询括起来,

curl -XGET "http://10.10.211.250:9200/company/_search" -H 'Content-Type: application/json' -d'
{
  "query":{
    "bool": {
      "should": [
        {
          "match": {
            "name": "foobar"
          }
        },
        {
          "match": {
            "shortName": {
              "query":"foobar",
              "boost":2.9  
            }
          }
        },
        {
          "wildcard": {
            "name.keyword": {
              "value":"*foobar*",
              "boost":7.5
            }
          }
        }
      ],
      "minimum_should_match": 1
    }
  },
  "from":0,
  "size":20
}'

所以我只能通过在Chrome浏览器中的url以下访问来获取搜索结果

http://10.10.211.250/company/search?keyword=foobar

Nginx可以达到目的吗?

location company/search {
    return 200 http://10.10.211.250:9200/company/_search 
}

0 个答案:

没有答案