TermFilter and TermQuery is not Working with not analysed field

Hi

I am using elasticsearch1.7.2 version,
The signature field which i am storing is not_analyzed while index creation is as follows
Column name is : signature
"signature" : { "type" : "string","index" : "not_analyzed","fielddata": {"format": "doc_values"}}
In the column the value is stored seems
String signature="PROTOCOL-DNS TMG Firewall Client long host entry exploit attempt "

I am trying to fetch the signature value using the following options as follows

query.must(QueryBuilders.termQuery("signature",signature));
andFilterBuilder.add(FilterBuilders.termFilter("signature",QueryParser.escape(signature)));
andFilterBuilder.add(FilterBuilders.termFilter("signature",signature));
It wont give the results using above,

The only way i am geeting the results with the following approach,
query.must(QueryBuilders.wildcardQuery("signature",""+signature+""));

Is i did anything wrong with the above query formation.Please suggest.

Thanks
Moni

term queries should work fine for analyzed fields. If wildcards work with surrounding +s maybe you have leading or trailing stuff in the signature? Like a trailing white space or something.

Hi Nik,

Thanks!

You are right ,Some strings have a trailing spaces which cause the result.

Is there any possible to check against whitespaces in the queries.
For not analysed fields which queries are the opt ?

Thanks Again

Moni

Found like a another one, I am storing the value is like "PROTOCOL-DNS TMG Firewall Client long host entry exploit attempt" in analysed filed.

When i am queried to the particular field in term query with the exact value , I am not getting the results.

But if i am passed the values by lowercase it's returns the result,
i have to pass lowercase always or any other alternatives.

Thanks
Moni