How to get score value of elasticsearch document from zdb query

70 views
Skip to first unread message

samanth...@gmail.com

unread,
Dec 12, 2016, 7:31:53 AM12/12/16
to ZomboDB
Hi,

I am using Zombo DB since few weeks. I am feeling so happy about the feature zombo is providing.

I have a requirement where I need score value of elasticsearch document.

Can you please help me to get score value?

Thanks,
Samanth

Eric B. Ridge

unread,
Dec 12, 2016, 2:34:34 PM12/12/16
to zom...@googlegroups.com
Hi Samanth! I'm pleased you like ZomboDB!

Scoring is pretty easy. ZDB provides a SQL function named
"zdb_score()" that works similarly to the "zdb()" function you use to
query. It is documented here:

https://github.com/zombodb/zombodb/blob/master/SQL-API.md#function-zdb_scoretable_name-regclass-ctid-tid-returns-float4

As the docs indicate, you can use the function as an output column and
use it in your ORDER BY clause (which is required if you want results
ordered by score).

If the docs don't provide enough information, please let me know.

eric
> --
> You received this message because you are subscribed to the Google
> Groups "ZomboDB" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to zombodb+u...@googlegroups.com.
> To post to this group, send email to zom...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/zombodb/2a9e075d-8019-4c86-a7b4-454fe75f0600%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.




samanth...@gmail.com

unread,
Dec 13, 2016, 2:14:12 AM12/13/16
to ZomboDB
Thank you very much! Eric.

I will check now.

Regards,
Samanth

samanth...@gmail.com

unread,
Dec 13, 2016, 12:46:40 PM12/13/16
to ZomboDB, samanth...@gmail.com

Thank you Eric. I am able to get the score of elasticsearch document

But my requirement is not satisfied. Here is my requirement:   I need matching score between search value and resultant records.

This is how I tried:
 I am getting different score values but I am expecting 100 as score value here, because I am doing exact search using class_id..
ex:-

SELECT zdb_score('recordid_gen.idserver_request_log', idserver_request_log.ctid), * FROM recordid_gen.idserver_request_log
WHERE zdb('recordid_gen.idserver_request_log', idserver_request_log.ctid) ==> 'class_id:("O.277968-840.205757.0")'



May be I am misunderstanding score value?

Please help me here how to get matching score..

Thanks,
Samanth

Eric B. Ridge

unread,
Dec 13, 2016, 2:44:03 PM12/13/16
to zom...@googlegroups.com, samanth...@gmail.com
What score value are you getting back? ZDB doesn't do anything special
with the scores. It simply returns whatever Elasticsearch calculates
the score to be.

eric
> https://groups.google.com/d/msgid/zombodb/8f991cfd-bde7-4849-b342-3040ba879f46%40googlegroups.com.

samanth...@gmail.com

unread,
Dec 22, 2016, 10:23:38 PM12/22/16
to ZomboDB, samanth...@gmail.com
Thank you! Eric. I will check with elasticsearch.

Regards,
Samanth
Reply all
Reply to author
Forward
0 new messages