Vue按条件查询elasticsearch(es)数据

1、让elasticsearch支持跨域

echo "http.cors.enabled: true" >> 向elasticsearch.yaml
echo "http.cors.allow-origin: /.*/" >>向elasticsearch.yaml

2、安装axios、编写js

npm install axios

3、编写js

let api = "http://www.xxx.com:9200/test/_search";
Axios({
  method: 'POST',
  url: api,
  data: {
  	"query": {
  		"bool": {
        	"must": [
                { "match": { "ProjectName": this.listQuery.info } },
                { "match": { "Status": "Error" } }
             ]
         }
     },
     "size": this.listQuery.page_size
        },
}).then(res => {
  console.log(res.data)
})

在这里插入图片描述

你可能感兴趣的:(java,java,后端)