mikegoatly / lifti

A lightweight full text indexer for .NET
MIT License
181 stars 9 forks source link

Add a "not contains" query operator #94

Open mikegoatly opened 9 months ago

mikegoatly commented 9 months ago

Proposal: Add a NOT operator to the query syntax, possibly something like eiffel !tower which would search for documents containing "eiffel" but not "tower".

Design questions

Should ! only be subtractive from the currently matched query results? For example, in the case of eiffel !tower we would match all documents containing eiffel, then subtract and documents and also contain tower.

This would mean that ! could not be used in isolation. For example, searching for !tower to match all the documents that don't contain tower, wouldn't work because it would logically equate to "no documents, subtracting any containing tower". It could be achieved using an expansive wildcard search followed by a negation, e.g. * !tower, but that's computationally expensive as we have to traverse the entire tree and return the locations of all tokens in all documents.

Originally created from #90