#community-help

Identifying Best Match Field in Document Search

TLDR Jack wanted to display the best match field in a document search. Despite Kishore Nallan's suggestion of looking at field weights, Jack decided to sort highlighted fields by number of matched tokens.

Powered by Struct AI

1

7
2w
Solved
Join the chat
Sep 19, 2023 (2 weeks ago)
Jack
Photo of md5-763597f84b704376f42cabfa33614ae8
Jack
12:46 PM
Is there a way to tell which field in a document was the "best" one when performing a search? I see a best_field_score field, but I can't see one telling me which field was the best?
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
12:47 PM
There's also a best field weight which might help identify the field. But weights are normalised so might not match exactly with values sent if the weight values are large.
12:48
Kishore Nallan
12:48 PM
Ofc if several fields share weights then this won't help.
Jack
Photo of md5-763597f84b704376f42cabfa33614ae8
Jack
12:48 PM
I'm not sending any specific weights right now, so I assume all of the fields are weighted the same.
12:49
Jack
12:49 PM
Essentially I want to show only the field that "most" matched the search term in the UI - is there another way to go about doing that?
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
12:50 PM
Hmm that's not quite possible
Jack
Photo of md5-763597f84b704376f42cabfa33614ae8
Jack
12:52 PM
I guess I'll just sort the highlight fields by number of matched tokens and pick the highest one then, cheers.

1