I wonder how it would be possible to implement a positional inverted index in MongoDB. By using the multikey feature an inverted index can be created, but how would it be possible to in a efficient way be able to store the positions of the occurences as well?
Let’s say we have this object
obj = {
name: "Apollo",
text: "Some text about Apollo moon landings",
keywords: [ "some", "text", "about", "apollo", "moon", "landings" ]
}
I would know like to be able to make a query where “apollo” and “landings” would have to be connected, and not just make an “intersection” query.
What about an object like:
You can do an ensureIndex on “keywords.text” to do a query where both keywords exists and then use javascript in a “where” filter to check relative positions of the input keywords.