Use BM25 score from Elasticsearch to order the results.

Hello Dear Janusgraph Community !
Hope every one does great these days.

I couldn't find an answer online, so trying my luck here.
Perhaps, you can help me understand how can I get Gremlin results sorted according to BM 25 search score provided by Elasticsearch.

So, I want to use mixed index with multiple vertex properties indexed as TEXT in ES and get the results based on full-text search with different boost weights.

For example, having mixed index include:
Property "Name" with boost of 0.5.
Property "Topic" with boost of 0.4.
Property "Desc" with boost of 0.1.

I would expect the results to be sorted with the relevance score as I execute my query
g.V().or(
  has('Name',textContainsPrefix("ProjectA")),
  has('Topic',textContainsPrefix("ProjectA"))
  has('Desc',textContainsPrefix("ProjectA"))
).order(score).by(name,topic,desc)

I could achieve the desired with querying index directly with indexQuery() method, getting the correct relevance score with getScore(), but I would very much like to have it working within gremlin ecosystem.
If it is not currently implemented, perhaps there is a way to customize the query and inject my own sorting and ordering mechanism using some smart steps like withSideEffect() or any other black-magic-trickery, if that Is that even possible ?

Thank you in advance for any help,
Michael
Was this page helpful?