I am using a Kibana query
GET /MY_INDEX_HERE/_search
{
"query": {
"match": {
"AccountId":
"bc73afda-d4f2"
}
}
}
and it is giving me the results, I expect. But when I use a terms query, it is not showing any result, although the values are same. There is no difference in any character or any case, everything is lower-case only.
My final goal is to get the result in my C# code. My query is
.Query(q => q.Raw(strQuery) && q.Terms(c => c.Name("by_account").Field(p => p.AccountsList).Terms(accountTerms))
With this query I am getting zero results, but if I comment the second query I am getting results:
.Query(q => q.Raw(strQuery) //&& q.Terms(c => c.Name("by_account").Field(p => p.AccountsList).Terms(accountTerms))
Right now my
strQuery ={\"bool\":{\"must\":[{\"match_phrase_prefix\":{\"fullname\":\"test\"}}]}}
and
List<string> accountTerms = new List<string>();
accountTerms.Add("bc73afda-d4f2");
The AccountId is a GUID type, I cant paste the full value here, hence it's not a complete value.
Troubleshooting Kibana 'terms' Query
The
termsquery is an exact match query, which means it doesn't analyze the query input or the field values before matching them.If the
AccountIdfield in your index has been mapped as akeywordfield or a text field with thekeywordtype, then the inputbc73afda-d4f2will be treated as a single term, and it will only match if the field value is an exact match, including case.Check the mapping of the
AccountId:If the
typeof the field istextorkeyword, Adjust your query to use the exact case and value of the field.Alternatively, you can use a
match_phrasequery instead of thetermsquery to match the exact phrase of theAccountIdfield, regardless of the case.