0

Similar to SQL I want to be able to search for terms, but instead of matching exact terms I want to be able to match terms that contains certain string say "abc".

Something like SQL's LIKE "%abc%"

At the moment I have the full term matcher like:

        AndFilterBuilder andFilter = FilterBuilders.andFilter();
        andFilter.add(FilterBuilders.rangeFilter("@timestamp").gt(start).lt(end));
        andFilter.add(FilterBuilders.termFilter("@host", "abc"));

Is there a way to do that? Regex may be?

Anton Belev
  • 11,963
  • 22
  • 70
  • 111
  • possible duplicate of http://stackoverflow.com/questions/6467067/how-to-search-for-a-part-of-a-word-with-elasticsearch please do not use "\*abc\*", it will be very slow, use ngram as described in the above link – ChintanShah25 Nov 14 '15 at 20:50

1 Answers1

1

Try using this:

andFilter.add(FilterBuilders.regexpFilter("@host", "*abc*")); 
Ankur Shanbhag
  • 7,746
  • 2
  • 28
  • 38
  • Thanks for your answer : ) I had just a small error in the regex it should be ".*abc.*". Otherwise it's working! – Anton Belev Nov 14 '15 at 21:01