OPTIONS

Haystack IndexesΒΆ

A haystack index is a special index that is optimized to return results over small areas. Haystack indexes improve performance on queries that use flat geometry.

For queries that use spherical geometry, a 2dsphere index is a better option than a haystack index. 2dsphere indexes allow field reordering; haystack indexes require the first field to be the location field. Also, haystack indexes are only usable via commands and so always return all results at once.

Haystack indexes create “buckets” of documents from the same geographic area in order to improve performance for queries limited to that area. Each bucket in a haystack index contains all the documents within a specified proximity to a given longitude and latitude.

To create a geohaystacks index, see Create a Haystack Index. For information and example on querying a haystack index, see Query a Haystack Index.

ON THIS PAGE