0

I have a field which has multiple strings, how do I write a search query for that with the RESTHightLevelCient. Also, the search string i give is just a partial string.


Adding a little more detail.

I am trying to implement something where I have multiple columns, but just one search string. My search string can be a combination of different columns; also my search should work when the string is just the combination of partial words from different columns.

I am trying a solution to get this working, by having a single column which is a space-separated join of all the other searchable columns in the order they can appear in the search.

So if I have 4 columns, Bookname, Author, Price, and Publication and when I give the partial book name with the partial author. I want the matches to be returned in the order where the most relevant match are on the top.

Ace
  • 700
  • 7
  • 37

1 Answers1

0

May be you can do a regexp search like this: (let the field name be "quotes" ):

BoolQueryBuilder searchFilter = QueryBuilders.boolQuery();
searchFilter.must(QueryBuilders.regexpQuery("quotes",".*err is to hum.*").flags(RegexpFlag.ALL));

This will return all quotes containing the expression "err is to hum" , for example a matching entry could be "To err is to human" .

.*___.* is for contains search (put search exp in place of dash)

.*___ ends with

___.* starts with

~.*____.* not containing

Hope this helps.

soumitra goswami
  • 818
  • 6
  • 29
  • what about if the search string is "er hum". Also, would the best approach be to use the "*"? – Ace Dec 06 '19 at 15:45