탄성 검색에서 데이터를 검색하려고합니다. 나는 elastc 검색에서 데이터를 인덱싱했으며 아래처럼 보입니다.탄성 검색에서 일부 필드 값을 기준으로 데이터 추출
{
"_index": "user",
"_type": "user_type",
"_id": "2393294",
"_version": 1,
"_score": 2,
"_source": {
"name": "shwn decker",
"worksFor": {
"legalName": "nykc private fund",
"address": "Mk street, bruke field"
},
},
"fields": {
"tweetDate": [
1457481600000
]
},
"sample_date":"10/10/2013"
}
"name"및 "legalName"필드를 기반으로 데이터를 검색하려고합니다. 몇 가지 쿼리를 시도했지만 두 필드를 기반으로 데이터를 필터링하려고 할 때 어떤 문서도 일치하지 않습니다. 내가 사용 쿼리는 다음과 같습니다
curl -XGET 'localhost:9200/user/user_type/_search?pretty' -H 'Content- Type: application/json' -d'
{
"query":{
"bool":{
"must":{
"query_string": {
"query": "shwn decker",
"fields": ["name"]
}
},
"filter":{
"term":{
"worksFor.legalName":"nykc private fund"
}
}
}
}
}'
내가 쿼리에서 무엇을해야 수정 나는 결과를 얻을 수 있도록. I는 다음과 같습니다이 데이터에 대한 사용자 정의 매핑을 사용하고 있습니다 :
{
"settings":
{
"number_of_shards" : 3,
"number_of_replicas" : 2
},
"mappings" : {
"user_type" : {
"properties" : {
"name" : {
"type" : "text",
"fields" : {
"raw" : {
"type":"keyword"
}
}
},
"worksFor" : {
"properties" : {
"address" : {
"type" : "text"
},
"legalName" : {
"type" : "text",
"fields" : {
"raw" : {
"type":"keyword"
}
}
},
}
}
}
}
}
}'
사용중인 ES 버전은 무엇입니까? – mickl
5.5 bool 쿼리를 지원합니다 – neha
데이터를 인덱싱하기 전에 매핑을 정의 했습니까? – mickl