You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Paul Taylor <pa...@fastmail.fm> on 2009/11/02 23:48:53 UTC
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@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: How do you map a query for fieldx to fieldy
Posted by Paul Taylor <pa...@fastmail.fm>.
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@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org