lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ben Dotte (JIRA)" <>
Subject [jira] Commented: (LUCENE-916) It is not possible to sort with sorttype auto on a field that does not exist
Date Thu, 07 Jun 2007 16:02:26 GMT


Ben Dotte commented on LUCENE-916:

I'm also having this problem. I'm trying to use Compass and originally reported the problem
in their forum:

But I agree this seems more like a problem with Lucene itself. I have written a junit testcase
that only uses Lucene objects that generates the same exception I was getting in Compass:

public class CompassSortTest extends TestCase
	public void testLuceneMultiSearcherSort() throws Exception
		RAMDirectory dir1 = new RAMDirectory();
		RAMDirectory dir2 = new RAMDirectory();
		Analyzer analyzer = new StandardAnalyzer();
		IndexWriter writer1 = new IndexWriter(dir1, analyzer, true);
		IndexWriter writer2 = new IndexWriter(dir2, analyzer, true);
		Document doc = new Document();
		doc.add(new Field("displayName", "obj1", Store.YES, Index.TOKENIZED));
		doc.add(new Field("id", "1", Store.YES, Index.UN_TOKENIZED));
		doc.add(new Field("sortField", "3", Store.NO, Index.UN_TOKENIZED));
		IndexSearcher searcher1 = new IndexSearcher(dir1);
		IndexSearcher searcher2 = new IndexSearcher(dir2);
		MultiSearcher multiSearcher = new MultiSearcher(new Searchable[] {searcher1, searcher2});
		QueryParser parser = new QueryParser("displayName", analyzer);
		Query query = parser.parse("o*");
		Sort sort = new Sort("sortField");
		Hits hits =, sort);
		assertEquals("2", hits.doc(0).get("id"));
		assertEquals("3", hits.doc(1).get("id"));
		assertEquals("1", hits.doc(2).get("id"));

The problem occurs when using a MultiSearcher that has at least one IndexSearcher tied to
a Directory with no documents in it. If I have 2 IndexSearchers, each with 1 document the
test passes. It is only when one of the IndexSearchers has no documents that the test fails.
The exception I get is "no terms in field sortField - cannot determine sort type" on
line 331.

> It is not possible to sort with sorttype auto on a field that does not exist
> ----------------------------------------------------------------------------
>                 Key: LUCENE-916
>                 URL:
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Search
>    Affects Versions: 1.9, 2.0.0, 2.0.1, 2.1, 2.2
>            Reporter: Daan de Wit
> When sorting with type auto on a field that does not exist, a RuntimeException is thrown
from line 346. This is especially a problem when using MultiSearcher.
This issue is related to:

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:
For additional commands, e-mail:

View raw message