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 John Wang <jo...@gmail.com> on 2005/02/16 23:39:52 UTC
knowing which field contributed the search result
Hi:
Is there way to find out given a hit from a search, find out which
fields contributed to the hit?
e.g.
If my search for:
contents1="brown fox" OR contents2="black bear"
can the document founded by this query also have information on
whether it was found via contents1 or contents2 or both.
Thanks
-John
---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org
Filtering Question
Posted by Luke Shannon <ls...@futurebrand.com>.
Hello;
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)path.next() + "*";
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 = searcher.search(query, 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?
Thanks,
Luke
---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org
Re: MultiField Queries without the QueryParser
Posted by Luke Shannon <ls...@futurebrand.com>.
Responding to this posts. Please disreguard.
Sorry.
----- Original Message -----
From: "Luke Shannon" <ls...@futurebrand.com>
To: "Lucene Users List" <lu...@jakarta.apache.org>
Sent: Tuesday, February 22, 2005 5:16 PM
Subject: MultiField Queries without the QueryParser
> Hello;
>
> The book meantions the MultiFieldQueryParser as one way of dealing with
> multifield queries. Can someone point me in the direction of other ways?
>
> Thanks,
>
> Luke
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: lucene-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org
MultiField Queries without the QueryParser
Posted by Luke Shannon <ls...@futurebrand.com>.
Hello;
The book meantions the MultiFieldQueryParser as one way of dealing with
multifield queries. Can someone point me in the direction of other ways?
Thanks,
Luke
---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org
Re: knowing which field contributed the search result
Posted by David Spencer <da...@tropo.com>.
John Wang wrote:
> Hi David:
>
> Can you further explain which calls specically would solve my problem?
Not in depth but anyway:
Examine the output of Explanation.toHtml() and/or
Explanation.toString(). Does it contain the info you want..if so call
the other Explanation methods and/or dig into the src if necessary.
getValue() is the score, so all that's missing is the name of the field
and I'm not sure if that's directly returned or not.
>
> Thanks
>
> -John
>
> On Mon, 21 Feb 2005 12:20:15 -0800, David Spencer
> <da...@tropo.com> wrote:
>
>>John Wang wrote:
>>
>>
>>>Anyone has any thoughts on this?
>>
>>Does this help?
>>
>>http://jakarta.apache.org/lucene/docs/api/org/apache/lucene/search/Searchable.html#explain(org.apache.lucene.search.Query,%20int)
>>
>>>Thanks
>>>
>>>-John
>>>
>>>
>>>On Wed, 16 Feb 2005 14:39:52 -0800, John Wang <jo...@gmail.com> wrote:
>>>
>>>
>>>>Hi:
>>>>
>>>> Is there way to find out given a hit from a search, find out which
>>>>fields contributed to the hit?
>>>>
>>>>e.g.
>>>>
>>>>If my search for:
>>>>
>>>>contents1="brown fox" OR contents2="black bear"
>>>>
>>>>can the document founded by this query also have information on
>>>>whether it was found via contents1 or contents2 or both.
>>>>
>>>>Thanks
>>>>
>>>>-John
>>>>
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
>>>For additional commands, e-mail: lucene-user-help@jakarta.apache.org
>>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: lucene-user-help@jakarta.apache.org
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: lucene-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org
Re: knowing which field contributed the search result
Posted by John Wang <jo...@gmail.com>.
Hi David:
Can you further explain which calls specically would solve my problem?
Thanks
-John
On Mon, 21 Feb 2005 12:20:15 -0800, David Spencer
<da...@tropo.com> wrote:
> John Wang wrote:
>
> > Anyone has any thoughts on this?
>
> Does this help?
>
> http://jakarta.apache.org/lucene/docs/api/org/apache/lucene/search/Searchable.html#explain(org.apache.lucene.search.Query,%20int)
> >
> > Thanks
> >
> > -John
> >
> >
> > On Wed, 16 Feb 2005 14:39:52 -0800, John Wang <jo...@gmail.com> wrote:
> >
> >>Hi:
> >>
> >> Is there way to find out given a hit from a search, find out which
> >>fields contributed to the hit?
> >>
> >>e.g.
> >>
> >>If my search for:
> >>
> >>contents1="brown fox" OR contents2="black bear"
> >>
> >>can the document founded by this query also have information on
> >>whether it was found via contents1 or contents2 or both.
> >>
> >>Thanks
> >>
> >>-John
> >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: lucene-user-help@jakarta.apache.org
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: lucene-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org
Re: knowing which field contributed the search result
Posted by David Spencer <da...@tropo.com>.
John Wang wrote:
> Anyone has any thoughts on this?
Does this help?
http://jakarta.apache.org/lucene/docs/api/org/apache/lucene/search/Searchable.html#explain(org.apache.lucene.search.Query,%20int)
>
> Thanks
>
> -John
>
>
> On Wed, 16 Feb 2005 14:39:52 -0800, John Wang <jo...@gmail.com> wrote:
>
>>Hi:
>>
>> Is there way to find out given a hit from a search, find out which
>>fields contributed to the hit?
>>
>>e.g.
>>
>>If my search for:
>>
>>contents1="brown fox" OR contents2="black bear"
>>
>>can the document founded by this query also have information on
>>whether it was found via contents1 or contents2 or both.
>>
>>Thanks
>>
>>-John
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: lucene-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org
Re: knowing which field contributed the search result
Posted by John Wang <jo...@gmail.com>.
Anyone has any thoughts on this?
Thanks
-John
On Wed, 16 Feb 2005 14:39:52 -0800, John Wang <jo...@gmail.com> wrote:
> Hi:
>
> Is there way to find out given a hit from a search, find out which
> fields contributed to the hit?
>
> e.g.
>
> If my search for:
>
> contents1="brown fox" OR contents2="black bear"
>
> can the document founded by this query also have information on
> whether it was found via contents1 or contents2 or both.
>
> Thanks
>
> -John
>
---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-user-help@jakarta.apache.org