Pg_trgm similarity ( text, text ) → real (postgresql Function) on ElasticSearch

Hello , i'm trying to imrpove the search time for a text from a postgresql database using Elasticsearch , the problem is the search returns a nameof product with best score using "similarity" function in Postgresql example :

```
select p.name  , similarity(p.name  , 'HORTIFRUTIGRANJEIROS/PITAYA') as sml
from products p 
order by sml desc limit 10
 ```

when changed to Elasticsearch , i used the java search API :

```
MatchQueryBuilder matchQueryBuilder = new MatchQueryBuilder("name", "HORTIFRUTIGRANJEIROS/PITAYA");
matchQueryBuilder.fuzziness(Fuzziness.AUTO);
searchSourceBuilder.query(matchQueryBuilder);
searchSourceBuilder.sort(new ScoreSortBuilder().order(SortOrder.DESC));
SearchRequest searchRequest = new SearchRequest();
searchRequest.source(searchSourceBuilder);
```

but the order of products with score in the response is very different ,
Is there any way to find something similaire to similarity() function on Elasticsearch ? knowing that it uses the trigram for search , i found some resources about n-gram on Elasticsearch but nothing for the java search API .

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.