Java Code Examples for org.elasticsearch.index.query.SimpleQueryStringBuilder

The following examples show how to use org.elasticsearch.index.query.SimpleQueryStringBuilder. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: act-platform   Source File: FactSearchManager.java    License: ISC License 4 votes vote down vote up
private QueryBuilder createFieldQuery(String field, String keywords) {
  SimpleQueryStringBuilder query = simpleQueryStringQuery(keywords)
          .field(field)
          // Values are indexed differently. Avoid errors when executing an IP search against a text field, for example.
          .lenient(true);
  // If field starts with the prefix 'objects.' it's part of the nested objects, thus, it must be wrapped inside a nested query.
  return field.startsWith("objects.") ? nestedQuery("objects", query, ScoreMode.Avg) : query;
}