1
votes

I am using Lucene in android to search my content. I have two types of documents and one has a trashed field which is either true or false. The other type of document does not have that field. I want to return all documents that have trashed:false, or don't have the trashed field.

I have tried add -trashed:true to my query, which returns all the correct documents, but it messes up the offsets of the search surround a different word and not the one I am searching for.

EDIT:

I have to add this to every search query I perform. I have an index of approximately 20,000 documents and I would really like to not have to rebuild it because I had my users rebuild their indices my last release. Note: this is on android devices so it takes a long time and a lot of battery to reindex all of their documents.

Thanks for the help.

1
"it messes up the offsets of the search surround a different word and not the one I am searching for" ? - Hakanai

1 Answers

0
votes

I can think of following solution.

1) If you can rebuild the index.

Add trashed:na field-value to the docs for which "trashed" is not applicable.

To get all the docs with trashed:false or "trashed" is not applicable, you can use following..

Query: trashed:false OR trashed:na

2) If you cannot rebuild the index, I am not sure...