제 질문은 입니다.입니다. 필터링 된 쿼리를 많이 사용하고 있으며 유형별로 쿼리하는 적절한 방법이 무엇인지 확신 할 수 없습니다. 위ElasticSearch에서 유형별로 쿼리하는 것이 더 좋습니까?
{
"my_index": {
"mappings": {
"type_Light_Yellow": {
"properties": {
"color_type": {
"properties": {
"color": {
"type": "string",
"index": "not_analyzed"
},
"brightness": {
"type": "string",
"index": "not_analyzed"
}
}
},
"details": {
"properties": {
"FirstName": {
"type": "string",
"index": "not_analyzed"
},
"LastName": {
"type": "string",
"index": "not_analyzed"
},
.
.
.
}
}
}
}
}
}
}
, 우리는 노란 빛이 유형 에 대해 하나의 매핑의 예를 볼 수 있습니다
그래서 먼저 매핑에서 봐 가지고 있습니다. 뿐만 아니라, 다양한 유형의 더 많은 매핑이 있습니다 (색상 예컨대 :. 어두운 노란색, 밝은 갈색 등등 ...)
주의하시기 바랍니다 color_type
의 서브 필드. 유형이 type_Light_Yellow
일 경우, 값은 항상 다른 모든 유형의 경우 "color": "Yellow", "brightness" : "Light"
입니다.
내 성능 질문 : 내 인덱스를 쿼리하는 데 좋아하는 방법이 있는지 궁금합니다.
예를 들어 "details.FirstName": "John"
과 "details.LastName": "Doe"
이 type_Light_Yellow
인 모든 문서를 검색해 보겠습니다.
내가 사용현재 방법
curl -XPOST 'http://somedomain.com:1234my_index/_search' -d '{
"query":{
"filtered":{
"filter":{
"bool":{
"must":[
{
"term":{
"color_type.color": "Yellow"
}
},
{
"term":{
"color_type.brightness": "Light"
}
},
{
"term":{
"details.FirstName": "John"
}
},
{
"term":{
"details.LastName": "Doe"
}
}
]
}
}
}
}
}'
으로 그 아래 또 다른 필드이었다로 유형 type_Light_Yellow
을, 나는 모든 인덱스를 쿼리하고 "color_type.color": "Yellow"
및 "color_type.brightness": "Light"
을 정의하고 참조하여, 상기 볼 수 있습니다 내가 찾는 문서들.
다른 방법은 종류에 따라 직접 쿼리하는 것입니다
curl -XPOST 'http://somedomain.com:1234my_index/type_Light_Yellow/_search' -d '{
"query": {
"filtered": {
"filter": {
"bool": {
"must": [
{
"term": {
"details.FirstName": "John"
}
},
{
"term": {
"details.LastName": "Doe"
}
}
]
}
}
}
}
}'
첫 선을 확인하십시오 : my_index/type_Light_Yellow/_search
.
- 성능을 통해 쿼리하는 것이 더 효율적입니까?
- 코드를 통해 쿼리 할 때 다른 답변이 될 수 있습니까 (저는 ElasticSearch 패키지와 함께 Python을 사용하고 있습니다)?