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 Chetan Shah <ch...@gmail.com> on 2009/02/26 19:45:14 UTC

TermsFilter Usage Question

Why is this code not returning any results?

            //Create the query and search
            QueryParser queryParser = new QueryParser("contents", new
StandardAnalyzer());
            Query query = queryParser.parse(searchCriteria);
                                               
            Term aTerm = new Term("categoryType");
            TermsFilter categoryFilter = new TermsFilter();      
            aTerm = aTerm.createTerm("xyz");
            categoryFilter.addTerm(aTerm);
                         
            TopDocs topDocs = indexSearcher.search(query, categoryFilter,
Constants.MAX_HITS);
            /** above line works if I null the filter **/

            ScoreDoc scoreDoc[] = topDocs.scoreDocs;
            int numDocs = scoreDoc.length;
            if (numDocs > 0) results = scoreDoc;   


If I do this for the line /**works...*// I get valid results.
TopDocs topDocs = indexSearcher.search(query, null, Constants.MAX_HITS);

The field "categoryType" is stored in the index. and I have confirmed via
Luke that "xyz" value is stored in the "categoryType" field.

Would highly appreciate if you can let me know what am I doing wrong here.
-- 
View this message in context: http://www.nabble.com/TermsFilter-Usage-Question-tp22230841p22230841.html
Sent from the Lucene - Java Users mailing list archive at Nabble.com.


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


Re: TermsFilter Usage Question

Posted by Chetan Shah <ch...@gmail.com>.
Yep. I searchcriteria and the category type value exists for a given
document. 
-- 
View this message in context: http://www.nabble.com/TermsFilter-Usage-Question-tp22230841p22231524.html
Sent from the Lucene - Java Users mailing list archive at Nabble.com.


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


Re: Query against newly created index.. Do not work

Posted by Chris Hostetter <ho...@fucit.org>.
: I can now create indexes with Nutch, and see them in Luke.. this is
: fantastic news, well for me it is beyond fantastic.. 
: Now I would like to (need to) query them, and to that end I wrote the
: following code segment.
: 
: 		int maxHits = 1000;
: 		NutchBean nutchBean = new NutchBean(nutchConf);
: 		Query nutchQuery = Query.parse(nutchSearchTerm,
: nutchConf);
: 		Hits nutchHits = nutchBean.search(nutchQuery, maxHits);
: 		return nutchHits.getLength();

...even though your code is written in java "java-user@lucene" isn't the 
appropriate mailing list for this type of question, java-user is for users 
of the Lucene Java API that is the underpinninings of Nutch (it's slightly 
confusing that the sub-projecct name has java in it)

If you ask your question on the nutch-user@lucene mailing list, i'm 
guessing you'll get a lot of feedback from people who are familiar with 
the Nutch java code.  (most people on this list probably have no idea what 
a NutchBean is)




-Hoss


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


Query against newly created index.. Do not work

Posted by "Lukas, Ray" <Ra...@idearc.com>.
 

I can now create indexes with Nutch, and see them in Luke.. this is
fantastic news, well for me it is beyond fantastic.. 
Now I would like to (need to) query them, and to that end I wrote the
following code segment.

		int maxHits = 1000;
		NutchBean nutchBean = new NutchBean(nutchConf);
		Query nutchQuery = Query.parse(nutchSearchTerm,
nutchConf);
		Hits nutchHits = nutchBean.search(nutchQuery, maxHits);
		return nutchHits.getLength();

In Luke if I do a query string like:

title:credit union

I receive 6 hits. The code above returns zero hits. I think that I am
doing this correctly, indeed coping this code directly from the WIKI
(thanks Chaz for giving us this).. 

searcher.dir, and plugin.folders inside of nutch-site.xml are correctly
set.

<property>
  <name>searcher.dir</name>
  <value>outputDir</value>
  <description>
 	 Path to root of crawl.  
  </description>
</property>
<property>
  <name>plugin.folders</name>
  <value>plugins</value>
  <description>
	Directories where nutch plugins are located.
  </description>
</property>

Any ideas? Oh and thanks for any help, of course.. 

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


Re: TermsFilter Usage Question

Posted by Erick Erickson <er...@gmail.com>.
Probably a silly question, but are you *also* sure that you
have documents with catetoryType:xyz AND the
values you are asking for in searchCriteria? I'd guess
that you could also check this out in Luke with a simple
+contests:blah +categoryType:xyz as a quick
sanity check.

The other thing it'd be interesting to do is prove that categoryFilter
had some bits turned on in its BitSet (or DocIdSet).

Best
Erick

On Thu, Feb 26, 2009 at 1:45 PM, Chetan Shah <ch...@gmail.com> wrote:

>
> Why is this code not returning any results?
>
>            //Create the query and search
>            QueryParser queryParser = new QueryParser("contents", new
> StandardAnalyzer());
>            Query query = queryParser.parse(searchCriteria);
>
>            Term aTerm = new Term("categoryType");
>            TermsFilter categoryFilter = new TermsFilter();
>            aTerm = aTerm.createTerm("xyz");
>            categoryFilter.addTerm(aTerm);
>
>            TopDocs topDocs = indexSearcher.search(query, categoryFilter,
> Constants.MAX_HITS);
>            /** above line works if I null the filter **/
>
>            ScoreDoc scoreDoc[] = topDocs.scoreDocs;
>            int numDocs = scoreDoc.length;
>            if (numDocs > 0) results = scoreDoc;
>
>
> If I do this for the line /**works...*// I get valid results.
> TopDocs topDocs = indexSearcher.search(query, null, Constants.MAX_HITS);
>
> The field "categoryType" is stored in the index. and I have confirmed via
> Luke that "xyz" value is stored in the "categoryType" field.
>
> Would highly appreciate if you can let me know what am I doing wrong here.
> --
> View this message in context:
> http://www.nabble.com/TermsFilter-Usage-Question-tp22230841p22230841.html
> Sent from the Lucene - Java Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

Re: TermsFilter Usage Question

Posted by Chetan Shah <ch...@gmail.com>.
Shooot........... The category type was stored by the not indexed! :teeth: 
The moment I flipped the flag of categoryType field to analyzed. I was able
to pull the results.
-- 
View this message in context: http://www.nabble.com/TermsFilter-Usage-Question-tp22230841p22231549.html
Sent from the Lucene - Java Users mailing list archive at Nabble.com.


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