You can always disable term frequencies on a field to eliminate the td-idf
issue, but then scoring would be affected and perhaps be more detrimental
than the original problem.

The standard solution in Lucene is to use payloads, which is metadata
associated with a term in the index. The synonym filter will add a weight
payload for each term and these weights will be read in the scorePayload
method of the Similarity class. The concept is simple, but it requires a
lot of boilerplate code for the analysis, querying parsing and the
similarity.

https://lucene.apache.org/core/4_7_0/core/org/apache/lucene/search/payloads/PayloadTermQuery.html

Cheers,

Ivan


On Sun, Mar 2, 2014 at 4:20 PM, Jake M <jakemagne...@gmail.com> wrote:

> I want to apply weights to different synonyms because in some cases we are
> not sure the relationship is legitimate or the relationship is not a true
> synonym. For example I would like 'doctor' and 'nurse' to be related such
> that a search for 'doctor' will also return documents containing 'nurse'
> but give them a lower score. What is the best way to achieve this
> functionality?
>
> I have found several examples of how to apply exact synonyms and these are
> the approaches I've considered so far but neither is exactly what I want
>
> A) Apply the synonym expansions at index time into different confidence
> synonym fields. This works but then tf-idf scoring for those fields is off
> because they only contain synonyms. The result is that a search for
> 'doctor' actually returns the results with 'nurse' first because it has
> higher term frequency being the only word in the synonym field.
>
> B) Use the built in synonyms support and apply synonym expansion or
> contraction as shown here:
> https://gist.github.com/clintongormley/4095280
> This works great but treats the synonyms as perfectly equal.
>
> Thanks!
>
>  --
> You received this message because you are subscribed to the Google Groups
> "elasticsearch" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elasticsearch+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/elasticsearch/af5439ea-1d03-4717-89d6-e79f9672cf7e%40googlegroups.com<https://groups.google.com/d/msgid/elasticsearch/af5439ea-1d03-4717-89d6-e79f9672cf7e%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elasticsearch+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQC%3Dsbp_MW1NQ8L-A4fKXjSxDAQc9zZLzW6Q1USYX73xRw%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to