Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apache Lucene Sort Issues with GAE-Lucene addDocuments #10

Open
vamsipkris opened this issue May 10, 2016 · 0 comments
Open

Apache Lucene Sort Issues with GAE-Lucene addDocuments #10

vamsipkris opened this issue May 10, 2016 · 0 comments

Comments

@vamsipkris
Copy link

vamsipkris commented May 10, 2016

I have been trying to get Sort working for Apache Lucene and Google App Engine. Here is what I am doing

I have a list of Documents, which I am putting into Lucene using the IndexWriter using addDocuments() method.

for(Object object : objects) {
    Document doc = new Document();
    document.add(new Field("id", generateDocId(object), idType));
    document.add(new NumericDocValuesField("sortLong",));
    documents.add(doc)
}

I am basically aggregating all the documents into a list and writing to index using

IndexWriter writer = getWriter();
writer.addDocuments(documents);

I am trying to query a few documents, based on some Query as well as Sort

Sort sort = new Sort(new SortField("sortLong", SortField.Type.LONG, true));
TopFieldDocs docs = searcher.search(new MatchAllDocsQuery(),2000,sort);

Problem:

When I use addDocuments to bulk index the documents, my Sort Queries are not returning the data in the correct Sort Order, basically they are wrong, however if I index each document using addDocument(), the Sort Queries are working correctly.

This has led me to deduce that there is something inherently wrong with addDocuments(). The sort wont work unless, I open the indexWriter, addDocument and Close the indexWriter. Which I am unwilling to do, because I have may thousands of records to index.

Is there any solution for this problem? Or is it a known defect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant