Home > Net >  @Query annotations in Spring Boot for elasticsearch to use Sort and Collapse
@Query annotations in Spring Boot for elasticsearch to use Sort and Collapse

Time:07-27

I have a question like can we use @Query annotations in elasticsearch to act as a nested query to use Sort and Collapse. my query looks like this::

GET clean/_search
{
  "query": {
    "match_phrase_prefix":{
      "search_term": "Monkey"
    }
  },

    "sort": [
      {
        "search_score": {
          "order": "desc"
        }
      }
    ],
    "collapse":{
        "field": "normalized_term"
    },
    "size": 10
}

This is the query, can I implement using @Query annotations and how can I implement this?

CodePudding user response:

No, you'd need to use a NativeSearchQuery where you can set a sort and collapse. The @Query annotation on a method defines only the query part sent to Elasticsearch.

  • Related