You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "steve neo (JIRA)" <ji...@apache.org> on 2009/05/08 17:25:45 UTC

[jira] Updated: (LUCENE-1631) CLONE -You cannot sort on fields that don't exist

     [ https://issues.apache.org/jira/browse/LUCENE-1631?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

steve neo updated LUCENE-1631:
------------------------------

          Description: 
I still get this error in 2.4.1 - if field does not exist in index,  there is nullPointException if it search over multiple index. In following test code, there is runtime error, here is part of test code. 


		indexSingleFieldDocs(new Field[]{new Field("ds", "xyz", Field.Store.YES, Field.Index.NOT_ANALYZED)
						, new Field("dsc", "hello", Field.Store.NO, Field.Index.ANALYZED)});
		indexSingleFieldDocs(new Field[]{new Field("ds", "def", Field.Store.YES, Field.Index.NOT_ANALYZED)
						, new Field("dsc", "hello", Field.Store.NO, Field.Index.ANALYZED)});

...

		QueryParser p = new QueryParser("dsc", new StandardAnalyzer());
		Query q = p.parse("hello");
		Hits hits = searcher.search(q,new Sort("ds"));


If change "ds" to some others,  got this exception:
java.lang.RuntimeException: field "ds" does not appear to be indexed
	at org.apache.lucene.search.ExtendedFieldCacheImpl$5.createValue(ExtendedFieldCacheImpl.java:173)
	at org.apache.lucene.search.FieldCacheImpl$Cache.get(FieldCacheImpl.java:71)
	at org.apache.lucene.search.ExtendedFieldCacheImpl.getAuto(ExtendedFieldCacheImpl.java:127)
	at org.apache.lucene.search.FieldSortedHitQueue.comparatorAuto(FieldSortedHitQueue.java:487)
	at org.apache.lucene.search.FieldSortedHitQueue$1.createValue(FieldSortedHitQueue.java:184)
	at org.apache.lucene.search.FieldCacheImpl$Cache.get(FieldCacheImpl.java:71)
	at org.apache.lucene.search.FieldSortedHitQueue.getCachedComparator(FieldSortedHitQueue.java:167)
	at org.apache.lucene.search.FieldSortedHitQueue.<init>(FieldSortedHitQueue.java:55)
	at org.apache.lucene.search.TopFieldDocCollector.<init>(TopFieldDocCollector.java:43)
	at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:121)
	at org.apache.lucene.search.Hits.getMoreDocs(Hits.java:113)
	at org.apache.lucene.search.Hits.<init>(Hits.java:90)
	at org.apache.lucene.search.Searcher.search(Searcher.java:61)
	at com.edgenius.test.lucene.TestLucene.testSort(TestLucene.java:207)


  was:
While it's possible to search for fields that don't exist (you'll get 0 hits),  
you'll get an exception if you try to sort by a field that has no values. The  
exception is this:  
  
if (termEnum.term() == null) {  
  throw new RuntimeException ("no terms in field " + field);  
}  
  
I'll attach a change suggested by Yonik Seeley that removes this exception. 
 
Also, the if-condition above is incomplete anyway, so currently the exception 
is not always thrown (as termEnum .term() might well be != null but point to a 
term in a different field already)

    Affects Version/s: 2.4.1

> CLONE -You cannot sort on fields that don't exist
> -------------------------------------------------
>
>                 Key: LUCENE-1631
>                 URL: https://issues.apache.org/jira/browse/LUCENE-1631
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Search
>    Affects Versions: 2.4.1
>         Environment: Operating System: other
> Platform: Other
>            Reporter: steve neo
>            Assignee: Yonik Seeley
>             Fix For: 1.9
>
>
> I still get this error in 2.4.1 - if field does not exist in index,  there is nullPointException if it search over multiple index. In following test code, there is runtime error, here is part of test code. 
> 		indexSingleFieldDocs(new Field[]{new Field("ds", "xyz", Field.Store.YES, Field.Index.NOT_ANALYZED)
> 						, new Field("dsc", "hello", Field.Store.NO, Field.Index.ANALYZED)});
> 		indexSingleFieldDocs(new Field[]{new Field("ds", "def", Field.Store.YES, Field.Index.NOT_ANALYZED)
> 						, new Field("dsc", "hello", Field.Store.NO, Field.Index.ANALYZED)});
> ...
> 		QueryParser p = new QueryParser("dsc", new StandardAnalyzer());
> 		Query q = p.parse("hello");
> 		Hits hits = searcher.search(q,new Sort("ds"));
> If change "ds" to some others,  got this exception:
> java.lang.RuntimeException: field "ds" does not appear to be indexed
> 	at org.apache.lucene.search.ExtendedFieldCacheImpl$5.createValue(ExtendedFieldCacheImpl.java:173)
> 	at org.apache.lucene.search.FieldCacheImpl$Cache.get(FieldCacheImpl.java:71)
> 	at org.apache.lucene.search.ExtendedFieldCacheImpl.getAuto(ExtendedFieldCacheImpl.java:127)
> 	at org.apache.lucene.search.FieldSortedHitQueue.comparatorAuto(FieldSortedHitQueue.java:487)
> 	at org.apache.lucene.search.FieldSortedHitQueue$1.createValue(FieldSortedHitQueue.java:184)
> 	at org.apache.lucene.search.FieldCacheImpl$Cache.get(FieldCacheImpl.java:71)
> 	at org.apache.lucene.search.FieldSortedHitQueue.getCachedComparator(FieldSortedHitQueue.java:167)
> 	at org.apache.lucene.search.FieldSortedHitQueue.<init>(FieldSortedHitQueue.java:55)
> 	at org.apache.lucene.search.TopFieldDocCollector.<init>(TopFieldDocCollector.java:43)
> 	at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:121)
> 	at org.apache.lucene.search.Hits.getMoreDocs(Hits.java:113)
> 	at org.apache.lucene.search.Hits.<init>(Hits.java:90)
> 	at org.apache.lucene.search.Searcher.search(Searcher.java:61)
> 	at com.edgenius.test.lucene.TestLucene.testSort(TestLucene.java:207)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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