Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Lucene: Java-User

How do you map a query for fieldx to fieldy

 

 

Lucene java-user RSS feed   Index | Next | Previous | View Threaded


paul_t100 at fastmail

Nov 2, 2009, 2:48 PM

Post #1 of 2 (137 views)
Permalink
How do you map a query for fieldx to fieldy

For backwards compatabiity I have to change queries for the track field
to the recording field. I did this by overriding QueryParser.newQuery()
as follows

protected Query newTermQuery(Term term) {
if ( term.field() == "track" ) {
return super.newTermQuery(new Term("recording"term.text()));
}
else {
return super.newTermQuery(term);
}
}

this seemed to work, but then I realised it didnt work for phrasequeries
so I have to override QueryParser.newPhraseQuery() but now thinking will
fail for wilcard queries ectera. Is there just one method I can override
to deal with this.


Paul

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe[at]lucene.apache.org
For additional commands, e-mail: java-user-help[at]lucene.apache.org


paul_t100 at fastmail

Nov 3, 2009, 3:54 AM

Post #2 of 2 (117 views)
Permalink
Re: How do you map a query for fieldx to fieldy [In reply to]

Paul Taylor wrote:
> For backwards compatabiity I have to change queries for the track
> field to the recording field. I did this by overriding
> QueryParser.newQuery() as follows
>
> protected Query newTermQuery(Term term) {
> if ( term.field() == "track" ) {
> return super.newTermQuery(new Term("recording"term.text()));
> }
> else {
> return super.newTermQuery(term);
> }
> }
>
> this seemed to work, but then I realised it didnt work for
> phrasequeries so I have to override QueryParser.newPhraseQuery() but
> now thinking will fail for wilcard queries ectera. Is there just one
> method I can override to deal with this.

FYI, did this instead and seems to work

protected Query getFieldQuery(String field, String queryText) throws
ParseException {
if( field.equals("track") {
field=RecordingIndexField.RECORDING.getName();
}
return super.getFieldQuery(field,queryText);
}

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe[at]lucene.apache.org
For additional commands, e-mail: java-user-help[at]lucene.apache.org

Lucene java-user RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.