0

The following code will throw an exception: [es/search] failed: [parsing_exception] unknown query [query].

    @Query(value = """
{
  "query": {
    "script_score": {
      "query": {
        "match_all": {}
      },
      "script": {
        "source": "cosineSimilarity(params.vector, doc['nameVector']) + cosineSimilarity(params.vector, doc['descriptionVector'])",
        "params": {
          "vector": ?0
        }
      }
    }
  },
  "sort": [
    { "_score": { "order": "desc" } }
  ]
}
""")

    Flux<SearchHit<ClubPO>> queryClubs(List<Double> vector);

The following code can run successfully.

    @Query("""
{
  "script_score": {
    "query": {
      "match_all": {}
    },
    "script": {
      "source": "cosineSimilarity(params.vector, doc['nameVector']) + cosineSimilarity(params.vector, doc['descriptionVector'])",
      "params": {
        "vector": ?0
      }
    }
  }
}
""")
    Flux<SearchHit<ClubPO>> queryClubs(List<Double> vector);

What should I do?

Are there any other annotations? For example, ones that support more raw query syntax?

# {"error":{"root_cause":[{"type":"parsing_exception","reason":"unknown query [query]","line":2,"col":12}],"type":"parsing_exception","reason":"unknown query [query]","line":2,"col":12,"caused_by":{"type":"named_object_not_found_exception","reason":"[2:12] unknown field [query]"}},"status":400}

1
  • Even though the query works, why is the returned _score NaN? Commented Jan 8 at 15:29

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.