Опитвах се наистина усилено, но се борех да направя това правилно. Всъщност в моето съпоставяне на индекса всички мои полета са низове от типове. напр
{"ind_ecue_fin_ult1":{"mappings":{"ind_ecue_fin_ult1":{"properties":{"age":{"type":"string"},"altaDiff":{"type":"string"},"antiguedad":{"type":"string"},"canal_entrada":{"type":"string"},"cod_prov":{"type":"string"},"conyuemp":{"type":"string"},"empIndex":{"type":"string"},"fecDiff":{"type":"string"},"gender":{"type":"string"},"ind_actividad_cliente":{"type":"string"},"indext":{"type":"string"},"indfall":{"type":"string"},"indrel":{"type":"string"},"indrel_1mes":{"type":"string"},"indresi":{"type":"string"},"nomprov":{"type":"string"},"nuevo":{"type":"string"},"others":{"type":"string"},"renta":{"type":"string"},"residence":{"type":"string"},"segmento":{"type":"string"},"tiprel_1mes":{"type":"string"},"wt":{"type":"double"}}}}}}
Използвайки python клиент за elasticsearch, генерирах следната заявка:
{'query': {'bool': {'minimum_should_match': 5,
'should': [{'boost': 4, 'terms': {'age': '1'}},
{'boost': 3, 'terms': {'antiguedad': '0.0'}},
{'boost': 3.5, 'terms': {'indrel': '1'}},
{'boost': 3, 'terms': {'indrel_1mes': '1'}},
{'boost': 2, 'terms': {'tiprel_1mes': 'A'}},
{'boost': 3, 'terms': {'indresi': 'S'}},
{'boost': 2.5, 'terms': {'indext': 'N'}},
{'boost': 2, 'terms': {'conyuemp': 'DEF'}},
{'boost': 2, 'terms': {'canal_entrada': 'KHL'}},
{'boost': 1.5, 'terms': {'indfall': 'N'}},
{'boost': 1.5, 'terms': {'cod_prov': '28'}},
{'boost': 2, 'terms': {'nomprov': 'MALAGA'}},
{'boost': 1.5, 'terms': {'ind_actividad_cliente': '1'}},
{'boost': 4, 'terms': {'renta': '1'}},
{'boost': 2.5, 'terms': {'segmento': '02 - PARTICULARES'}},
{'range': {'wt': {'boost': 5.0, 'gte': 0.4, 'lte': 0.525}}}]}}}
Получавам обаче това изключение, дори ако опитам който и да е термин от масив в "трябва":
curl -XPOST "htturl -XPOST "http://localhost:9200/ind_ahor_fin_ult1/_search" -d'
{"query": {"bool": {"minimum_should_match": 5,
"should": [{"terms": {"renta": "1"},"boost": 4}]}}}'
{"error":{"root_cause":[{"type":"query_parsing_exception","reason":"[terms] query does not support [renta]","index":"ind_ahor_fin_ult1","line":3,"col":35}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"query","grouped":true,"failed_shards":[{"shard":0,"index":"ind_ahor_fin_ult1","node":"j20MAn_OQ9eRyNsrjf1MRQ","reason":{"type":"query_parsing_exception","reason":"[terms] query does not support [renta]","index":"ind_ahor_fin_ult1","line":3,"col":35}}]},"status":400}
Моля помогнете. TIA.