Full Text Search - how do I retrieve the score of a document?

428 views
Skip to first unread message

jon

unread,
Jun 11, 2012, 4:59:07 AM6/11/12
to Google App Engine
Hi,

For a given ScoredDocument, how do I get its "relevance score"? The
official example app doesn't demonstrate scoring. This documentation
implies that QueryOptions.Builder has a setScorer() method but it
doesn't exist. https://developers.google.com/appengine/docs/java/javadoc/com/google/appengine/api/search/Query

I can see that ScoredDocument has a getSortScores() method that
returns a List. I'm not quite sure what this is. I will try it out and
see what it does. In the meantime if someone has some info on scoring
I'll be grateful if you can shed some light.

Thanks,
Jon

Phil McDonnell

unread,
Sep 5, 2012, 6:01:17 PM9/5/12
to google-a...@googlegroups.com
Does anyone have an example of how they implemented scoring using the Text Search API? The documentation exposes ANDs and ORs in the search query with a sort ASC/DESC type of sorting on a field, but that sorting is not super helpful for most search applications. I imagine most any real use case here needs scoring implemented. Any examples out there?

Thanks,
Phil


--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To post to this group, send email to google-a...@googlegroups.com.
To unsubscribe from this group, send email to google-appengi...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.


jon

unread,
Sep 11, 2012, 10:42:18 PM9/11/12
to google-a...@googlegroups.com
I'm afraid my original question is still unanswered. I still don't know how to grab relevance score. I have a feeling that there's no Googler that's been assigned to look after FTS questions in this group :-(

Amy Unruh

unread,
Sep 12, 2012, 12:51:49 AM9/12/12
to google-a...@googlegroups.com
hi,

The match scorer does relevance scoring based on term frequency.  You can configure it as a sort option:
QueryOptions.newBuilder()
    .setSortOptions(SortOptions.newBuilder()
        .setMatchScorer(MatchScorer.newBuilder()))
    ...
    .build();

then access the scores in the query results:
for (ScoredDocument scoredDoc : results) {
    out.println("Score: " + scoredDoc.getSortScores().get(0));
}

If you access _score in a sort expression, e.g (suppose you have a field called 'price'):

SortExpression sortExpr = SortExpression.newBuilder()
    .setExpression("price + _score")
    .setDefaultValueNumeric(0.0)
    .build();

then your SortOptions object should include a scorer. e.g.:

SortOptions.newBuilder()
    .setMatchScorer(MatchScorer.newBuilder())
    .addSortExpression(sortExpr)
    ...
    .build();

You might find the examples in this set of slides useful: http://fts-webinar.appspot.com/ .  Both python and java examples are included.



On 12 September 2012 12:42, jon <jonni...@gmail.com> wrote:
I'm afraid my original question is still unanswered. I still don't know how to grab relevance score. I have a feeling that there's no Googler that's been assigned to look after FTS questions in this group :-(

--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-appengine/-/bn2-B7VbApEJ.
Reply all
Reply to author
Forward
0 new messages