lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Luke Shannon" <>
Subject Filtering Question
Date Wed, 23 Feb 2005 19:28:18 GMT

I'm trying to create a Filter that only retrieves documents with a path
field containing a sub string(s).

I can get the Filter to work if the BooleanQuery below (used to create the
Filter) contains only TermQueries (this requires me to know the exact path).
But not if it contains Wildcard?

Here is the code to create the filter:

//if the paths parameter is null we don't use the filter
        boolean useFilter = false;
        BooleanQuery filterParams = new BooleanQuery();
        if (paths != null) {
            useFilter = true;
            Trace.DEBUG("The query will have a filter with " + paths.size()
+ " terms.");
            Iterator path = paths.iterator();
            while (path.hasNext()) {
                String strPath = "*" + (String) + "*";
                Trace.DEBUG(strPath + " is one of the params");
                filterParams.add(new WildcardQuery(new Term("path",
strPath)), false, false);

        Trace.DEBUG("The filter is created using this: " + filterParams);
        Filter pathFilter = new QueryFilter(filterParams);
        Trace.DEBUG("The filter is " + pathFilter.toString());

When useFilter is true, the search is executed with pathFilter as the second
parameter -> hits =, pathFilter);

Here is a small output, without the filter this query returns all the
documents in the index. With it, 6 should be coming back.

*testing* is one of the params
The filter is created using this: path:*testing*
The filter is QueryFilter(path:*testing*)
The query: olfaithfull:*stillhere* returned 0

Why won't this work?



To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message