You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by Mark Miller <ma...@gmail.com> on 2009/11/06 19:37:56 UTC

getField on MultiTermQuery

Now that getTerm is gone from MultiTermQuery, I'd like to add some way
to get the field. The Highlighter has to now do more nasty
specialization than it already did to get the field off every type of
MultiFieldQuery. So some contrib queries that worked now don't, and are
going to require a dependency and instanceof handling to work again.
Annoying, because its just to get the field. So I'd like to add getField
or field. Unfortunately, it would have to throw UnsupportedException or
return null or something for back compat, unless someone has a bright
idea about how to solve this in another way (in the near term).

-- 
- Mark

http://www.lucidimagination.com




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


RE: getField on MultiTermQuery

Posted by Uwe Schindler <uw...@thetaphi.de>.
> On Fri, Nov 6, 2009 at 1:52 PM, Uwe Schindler <uw...@thetaphi.de> wrote:
> > We should add a getField() to the Query class itsself so we have support
> to
> > get the field in all queries.
> 
> Urg... now you owe me another beer.

Yes, that was a bad idea, you'll get a beer this evening :-)

But a solution not only for MTQ would be (it would remove a lot of
instanceof checks in Highlighter to get the terms):

We define an interface (do not hurt me, but interfaces that have a clear
meaning and never tend to be extended are just fine, like the
AttributeSource stuff), that has a getField() method. All queries that
support retrieving a field name can implement this interface:

public interface FieldedQuery {
	String getField();
}

If you have a better name, tell me, but not
"SmartFancyHighlighterInterface".

I think Mark Miller was quite happy about that idea. Now you just have one
instanceof check there and then cast to that interface to get the field
name.

Uwe


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


Re: getField on MultiTermQuery

Posted by Yonik Seeley <yo...@lucidimagination.com>.
On Fri, Nov 6, 2009 at 1:52 PM, Uwe Schindler <uw...@thetaphi.de> wrote:
> We should add a getField() to the Query class itsself so we have support to
> get the field in all queries.

Urg... now you owe me another beer.

-Yonik
http://www.lucidimagination.com

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


RE: getField on MultiTermQuery

Posted by Uwe Schindler <uw...@thetaphi.de>.
We should add a getField() to the Query class itsself so we have support to
get the field in all queries. For MTQ the default impl could be the one
Simon proposed.

Uwe

-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: uwe@thetaphi.de

> -----Original Message-----
> From: Simon Willnauer [mailto:simon.willnauer@googlemail.com]
> Sent: Friday, November 06, 2009 10:50 AM
> To: java-dev@lucene.apache.org
> Subject: Re: getField on MultiTermQuery
> 
> I would try to subclass Multitermquery and call the getEnum in some
> kind of a Extractor class like :
> 
> public class TermExtractor extends MultiTermQuery{
> 
>   private MultiTermQuery q;
> 
>   public TermExtractor(MultiTermQuery q){
>     this.q = q;
>   }
>   public String getField(IndexReader reader) throws IOException{
>      FilteredTermEnum enum1 = this.q.getEnum(reader);
>      return enum1.currentTerm.field();
>   }
> 
> that would give you a generic way to extract the terms field...
> 
> would that help the highlighter though?
> 
> simon
> 
> On Fri, Nov 6, 2009 at 7:37 PM, Mark Miller <ma...@gmail.com> wrote:
> > Now that getTerm is gone from MultiTermQuery, I'd like to add some way
> > to get the field. The Highlighter has to now do more nasty
> > specialization than it already did to get the field off every type of
> > MultiFieldQuery. So some contrib queries that worked now don't, and are
> > going to require a dependency and instanceof handling to work again.
> > Annoying, because its just to get the field. So I'd like to add getField
> > or field. Unfortunately, it would have to throw UnsupportedException or
> > return null or something for back compat, unless someone has a bright
> > idea about how to solve this in another way (in the near term).
> >
> > --
> > - Mark
> >
> > http://www.lucidimagination.com
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
> > For additional commands, e-mail: java-dev-help@lucene.apache.org
> >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-dev-help@lucene.apache.org



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


Re: getField on MultiTermQuery

Posted by Simon Willnauer <si...@googlemail.com>.
I would try to subclass Multitermquery and call the getEnum in some
kind of a Extractor class like :

public class TermExtractor extends MultiTermQuery{

  private MultiTermQuery q;

  public TermExtractor(MultiTermQuery q){
    this.q = q;
  }
  public String getField(IndexReader reader) throws IOException{
     FilteredTermEnum enum1 = this.q.getEnum(reader);
     return enum1.currentTerm.field();
  }

that would give you a generic way to extract the terms field...

would that help the highlighter though?

simon

On Fri, Nov 6, 2009 at 7:37 PM, Mark Miller <ma...@gmail.com> wrote:
> Now that getTerm is gone from MultiTermQuery, I'd like to add some way
> to get the field. The Highlighter has to now do more nasty
> specialization than it already did to get the field off every type of
> MultiFieldQuery. So some contrib queries that worked now don't, and are
> going to require a dependency and instanceof handling to work again.
> Annoying, because its just to get the field. So I'd like to add getField
> or field. Unfortunately, it would have to throw UnsupportedException or
> return null or something for back compat, unless someone has a bright
> idea about how to solve this in another way (in the near term).
>
> --
> - Mark
>
> http://www.lucidimagination.com
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-dev-help@lucene.apache.org
>
>

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