Hi All,
I try to find a value ( from different field" ) in two index. ( and return false if the value is not present in the two indexes.
here is my examples.
I have an index ( known_issues ) filled with the current error already identified
by ex: 2 issues
POST /known_issues/doc
{
"id": "issue1",
"description": "file not found"
}
POST /known_issues/doc
{
"id": "issue2",
"description": "syntax error"
}
and another index with the log of each test.
POST /test_log/doc
{
"id": "id1",
"test_case": "a test case",
"result": "syntax error"
}
POST /test_log/doc
{
"id": "id2",
"test_case": "another test case",
"result": "success"
}
I would like to find by a query , all tests ( from test_log) with an issue already identified ( from known_issues )
my query is :
GET /known_issues,test_log/_search
{
"query": {
"multi_match": {
"query": "syntax error",
"type": "phrase",
"fields": [
"description",
"result"
],
"operator": "and"
}
}
}
I'm really happy, the request finds 2 hits, one in each index.
{
"took": 0,
....
},
"hits": {
**"total": 2,**
"hits": [
{
"_index": "known_issues",
"_source": {
"id": "issue2",
"description": "syntax error"
}
},
{
"_index": "test_log",
"_source": {
"id": "id1",
"test_case": "a test case",
"result": "syntax error"
}
}
]
}
}
BUT
, this request returns 1 hit , it there is no entries in known_issues index ! why ?!
the operator "and" did not do what i was expecting.
ex :
delete known_issues
POST /known_issues/doc
{
"id": "issue1",
"description": "file not found"
}
POST /known_issues/doc
{
"id": "issue2",
"description": "syntax_ERROR"
}
my query returns :
{
"took": 0,
"timed_out": false,
"_shards": {...},
"hits": {
**"total": 1,**
"max_score": 0.5753642,
"hits": [
{
"_index": "test_log",
"_type": "doc",
"_id": "MkOK1WMBOroXuELibpK5",
"_score": 0.5753642,
"_source": {
"id": "id1",
"test_case": "a test case",
"result": "syntax error"
}
}
]
}
}
I tested with a bool, must ,should, etc etc .... nothing work!
Shall i change my idea ? in a python script, i can get all known issues and make a query for each test_log ? but i lose the power of ES;
Any help , will be welcome
Thanks
Philippe.