lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Todd McGrath" <mcgr...@supergloo.com>
Subject newbie Filter question
Date Thu, 17 Oct 2002 18:58:46 GMT
Hello,

Struggling with an issue when using Filters to limit search results:

Background:
I create and index of articles from a database. Code to search is running
fine.  Now, I'm trying to implement filters to limit results of search.
Users should only see results if they subscribe to the topics in which the
articles are associated.  Articles may be associated with 1 or many topics.

When I create the index, I have a Field called topics that contains space
delimited values for topics:

Example:
Document d = new Document();
d.add(Field.UnStored("topics", "topic1 topic2 topic3 top firms bacteria
blood");

I created an ArticleFilter class with the following bits method:

public java.util.BitSet bits(IndexReader reader) throws java.io.IOException
{
	BitSet bits = new BitSet(reader.maxDoc());

	//field and text set in ArticleFilter constructor
	TermDocs termDocs = reader.termDocs(new Term(field, text));

	if (termDocs == null) {
		return bits;
	}

	try {
	  while (termDocs.next())
	    bits.set(termDocs.doc());
	} finally {
	  termDocs.close();
	}

	return bits;
}

ArticleFilters are created based on what topics the user is subscribed.


Here is the issue:
When a result is filtered that contains a topic with no spaces (example:
topic1) everything is fine.  But, when the result is filtered with a topic
that contains spaces (example: top firms), there are no results.  In my test
cases, if I hard code a filter with just "top" or create two filters: "top"
and "firms", there are results.

I have a feeling this is related to filter terms being tokenized.  What are
the best ways to use a filter where the text contains spaces?

I searched the FAQ and mailing list, but I didn't find anything so far.

Todd



--
To unsubscribe, e-mail:   <mailto:lucene-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-user-help@jakarta.apache.org>


Mime
View raw message