lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Tignor <>
Subject customized SpanQuery Payload usage
Date Tue, 24 Nov 2009 14:56:19 GMT

For certain span queries I construct problematically by piecing together my
own SpanTermQueries I would like to enforce that Payload data is not
returned for matches on those specific terms used by the constituent

For exmaple if I search for a position match with a SpanQuery referencing
the tokens "_n" and "work" and there is Payload data for each (there needs
to be for other types of queries) I would like to be able to screen out the
payload data originating from any matched "_n" tokens.

I thought for the tokens I am not interested in receiving payload data from
I might simply create (anonymously) my own subclass of SpanTermQuery which
overrides getSpans and returns another custom class which extends TermSpans
but there simply overrides isPayloadAvailable to return false:

new SpanTermQuery(new Term(myField, myTokenString)) {

                                public Spans getSpans(IndexReader reader)
                                        throws IOException {
                                    return new
TermSpans(reader.termPositions(term), term) {

                                        public boolean isPayloadAvailable()
                                            return false;


This however seems to eliminating payload data for all matches though I'm
not sure why and am tracing through the code, looking at NearSpansUnordered.

Any thoughts?

thanks so much,



Christopher Tignor | Senior Software Architect
155 Spring Street NY, NY 10012
p.212-285-8600 x385 f.212-285-8999

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message