Elastic4s: score remains at 1 with rawQuery

We use flexible4s for ElasticSearch 2.2.0. A number of queries are stored as JSON on disk and used as rawQuery through the flexible4s driver. The score as a result differs between the request sent through the command line or the elastic4s driver. The flexible4s driver always returns a result of 1 for all results, and command line execution gives two different values ​​(for different data types).

Code for elastic 4s:

val searchResult = client.execute { search in indexName types(product, company, orga, "User", "Workplace") rawQuery preparedQuery sourceInclude(preparedSourceField:_*) sort {sortDefintions:_*} start start limit limit }.await 

Please note that I deleted anything other than rawQuery preparedQuery and it did not change the score of 1 . The full command line request is quite long:

 { "query": { "bool": { "must": [ { "multi_match": { "query": "${search}", "fields": [ "name", "abbreviation", "articleNumberManufacturer", "productLine", "productTitle^10", "productSubtitle", "productDescription", "manufacturerRef.name", "props" ] } } ], "filter": [ { "or": [ { "bool": { "must": [ { "type": { "value": "Product" } }, { "term": { "publishState": "published" } } ], "must_not": [ { "term": { "productType": "MASTER" } }, { "term": { "deleted": true } } ] } } ] } ] } } } 

Note that this is almost preparedQuery , but to replace $search search query. A robust REST client lookup returns 3.075806 for matches.

+5
source share
1 answer

elastic4s rawQuery transfer your rawQuery-JSON to another query object.

he like you requested for

 { "query": { "query": { "bool": { "must": [ { "multi_match": { "query": "${search}", ... 

just delete your "request" for packaging from JSON, and the answer will show different points.

Alternatively, you can use extraSource instead of rawQuery , as described in elastic4s document. although this did not work for me at all:

ErrorMessage: value extraSource is not a member of com.sksamuel.elastic4s.SearchDefinition

0
source

Source: https://habr.com/ru/post/1247938/


All Articles