You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+168Lines changed: 168 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -582,6 +582,174 @@ The Elasticsearch Query Builder has a couple of family of methods that can be ov
582
582
In Mongo and Postgres there is a near 1-1 translation between an AST node and a query. In Elasticsearch, due to [Nested Queries](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-nested-query.html) the mapping is not 1-to-1,
583
583
due to visiting a nested field. If you need to override behaviour pertaining to a nested field, the `Get____QueryBuilder()` functions are probably where the override should happen, otherwise `Visit____()` might be simpler.
584
584
585
+
#### MongoDB Atlas Search (Beta)
586
+
587
+
The following example shows how to generate a MongoDB Atlas Search query with this library.
588
+
589
+
**Note**: MongoDB Atlas Search support is currently in beta. Some operators & types are not yet implemented.
WildcardCaseInsensitive: "caseInsensitiveAnalyzer", // Used for ILIKE
730
+
WildcardCaseSensitive: "caseSensitiveAnalyzer", // Used for LIKE
731
+
},
732
+
}
733
+
```
734
+
735
+
**Behavior:**
736
+
If a field is **not** in `FieldToMultiAnalyzers`, if you specify a non empty analyzer, then a "multi" attribute is generated with the name (e.g., `{"path": {"value": "fieldName", "multi": "analyzerName"}}`)
737
+
738
+
This allows you to mix fields with and without multi-analyzer support in the same index.
739
+
740
+
##### Limitations
741
+
742
+
1. The following operators are not yet implemented: `contains`, `contains_any`, `contains_all`, `is_null`
743
+
2. The following field types are not currently supported: UUID fields, Date fields, Numeric fields (numbers are compared as strings)
744
+
3. Range operators (`gt`, `ge`, `lt`, `le`) perform lexicographic comparison on string fields only
745
+
4. Atlas Search requires proper [search index configuration](https://www.mongodb.com/docs/atlas/atlas-search/create-index/) with appropriate field types:
746
+
- String fields used with `like`/`ilike` should be indexed with multi-analyzers as shown above
747
+
- String fields used with `eq`/`in` should be indexed with `token` type
748
+
- String fields used with range operators (`gt`/`ge`/`lt`/`le`) work with `token` type for lexicographic comparison
749
+
- Text fields should be indexed with `string` type and an appropriate analyzer
750
+
5. Unlike regular MongoDB queries, Atlas Search queries use the aggregation pipeline with the `$search` stage
751
+
6. Additional filters (like tenant boundaries) should be included within the `$search` stage using compound must clauses for optimal performance (as shown in the example above). Alternatively, they can be added as separate `$match` stages after the `$search` stage, though this is less efficient as it filters results after the search rather than during indexing
0 commit comments