-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add queryString operator to Atlas Search #1588
Changes from 2 commits
f884705
1e31394
85c3580
bf298b3
a0a60ba
52487b3
392a1af
29a3da5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright 2008-present MongoDB, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.mongodb.client.model.search; | ||
|
||
import com.mongodb.annotations.Beta; | ||
import com.mongodb.annotations.Reason; | ||
import com.mongodb.annotations.Sealed; | ||
|
||
/** | ||
* @see SearchOperator#queryString(SearchPath, String) | ||
* @since 5.3 | ||
*/ | ||
@Sealed | ||
@Beta(Reason.CLIENT) | ||
public interface QueryStringSearchOperator extends SearchOperator { | ||
@Override | ||
QueryStringSearchOperator score(SearchScore modifier); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -228,6 +228,17 @@ object SearchOperator { | |
def near(origin: Point, pivot: Number, paths: Iterable[_ <: FieldSearchPath]): GeoNearSearchOperator = | ||
JSearchOperator.near(origin, pivot, paths.asJava) | ||
|
||
/** | ||
* Returns a `SearchOperator` that supports querying a combination of indexed fields and values. | ||
* | ||
* @param defaultPath The field to be searched by default. | ||
* @param query One or more indexed fields and values to search. | ||
* @return The requested `SearchOperator`. | ||
* @see [[https://www.mongodb.com/docs/atlas/atlas-search/queryString/ queryString operator]] | ||
*/ | ||
def queryString(defaultPath: SearchPath, query: String): QueryStringSearchOperator = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @katcharov Shouldn't we also include the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I left out the |
||
JSearchOperator.queryString(defaultPath, query) | ||
|
||
/** | ||
* Creates a `SearchOperator` from a `Bson` in situations when there is no builder method that better satisfies your needs. | ||
* This method cannot be used to validate the syntax. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should not be possible to write
queryString(wildcardPath(...
- though the query supports wildcards, I believe the defaultPath itself does not. Could you confirm?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, will change
SearchPath
toFieldSearchPath
to limit defaultPath to use wildcardPath!