[ 
https://issues.apache.org/jira/browse/LUCENE-4499?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13507243#comment-13507243
 ] 

Nolan Lawson commented on LUCENE-4499:
--------------------------------------

I had similar problems with multi-word synonyms, and I largely resolved them by 
moving all the synonym expansion logic into the query parser.  I have a 
description of it on my blog [1] and some open-source code on GitHub [2].

In terms of changes to Solr/Lucene, all my code adds is an extension to the 
EDismaxQueryParserPlugin, so it's easy to install.

And at the very least, with my code you would be able to query "hubble NEAR 
telescope" as in your example, and it would work because the index tokens have 
not been changed at all.  "HST" would also work.

It's not exactly like your solution, but I think mine could be an interesting 
addition to Solr, and could help folks out who have run into similar issues 
with multi-word synonyms.

Links:
[1] http://nolanlawson.com/2012/10/31/better-synonym-handling-in-solr/
[2] https://github.com/healthonnet/hon-lucene-synonyms#readme
                
> Multi-word synonym filter (synonym expansion)
> ---------------------------------------------
>
>                 Key: LUCENE-4499
>                 URL: https://issues.apache.org/jira/browse/LUCENE-4499
>             Project: Lucene - Core
>          Issue Type: Improvement
>          Components: core/other
>    Affects Versions: 4.1, 5.0
>            Reporter: Roman Chyla
>            Priority: Minor
>              Labels: analysis, multi-word, synonyms
>             Fix For: 5.0
>
>         Attachments: LUCENE-4499.patch
>
>
> I apologize for bringing the multi-token synonym expansion up again. There is 
> an old, unresolved issue at LUCENE-1622 [1]
> While solving the problem for our needs [2], I discovered that the current 
> SolrSynonym parser (and the wonderful FTS) have almost everything to 
> satisfactorily handle both the query and index time synonym expansion. It 
> seems that people often need to use the synonym filter *slightly* differently 
> at indexing and query time.
> In our case, we must do different things during indexing and querying.
> Example sentence: Mirrors of the Hubble space telescope pointed at XA5
> This is what we need (comma marks position bump):
> indexing: mirrors,hubble|hubble space 
> telescope|hst,space,telescope,pointed,xa5|astroobject#5
> querying: +mirrors +(hubble space telescope | hst) +pointed 
> +(xa5|astroboject#5)
> This translated to following needs:
>   indexing time: 
>     single-token synonyms => return only synonyms
>     multi-token synonyms => return original tokens *AND* the synonyms
>   query time:
>     single-token: return only synonyms (but preserve case)
>     multi-token: return only synonyms
>  
> We need the original tokens for the proximity queries, if we indexed 'hubble 
> space telescope'
> as one token, we cannot search for 'hubble NEAR telescope'
> You may (not) be surprised, but Lucene already supports ALL of these 
> requirements. The patch is an attempt to state the problem differently. I am 
> not sure if it is the best option, however it works perfectly for our needs 
> and it seems it could work for general public too. Especially if the 
> SynonymFilterFactory had a preconfigured sets of SynonymMapBuilders - and 
> people would just choose what situation they use. Please look at the unittest.
> links:
> [1] https://issues.apache.org/jira/browse/LUCENE-1622
> [2] http://labs.adsabs.harvard.edu/trac/ads-invenio/ticket/158
> [3] seems to have similar request: 
> http://lucene.472066.n3.nabble.com/Proposal-Full-support-for-multi-word-synonyms-at-query-time-td4000522.html

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org

Reply via email to