feat(firestore): Implement Search pipeline stage and related expressions#14383
feat(firestore): Implement Search pipeline stage and related expressions#14383bhshkh merged 4 commits intogoogleapis:mainfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds the Search pipeline stage and associated functions like DocumentMatches, GeoDistance, and Snippet to the Firestore SDK. The changes include protobuf mapping, unit tests, and integration tests. Feedback focuses on correcting documentation examples that used incorrect method signatures and recommending the use of the idiomatic GeoPoint type instead of internal proto types for geospatial coordinates. A simplification of the protobuf conversion logic in the search stage was also suggested.
|
Snippet will not be supported at launch. Are you seeing that it is supported in your testing? |
| // | ||
| // Experimental: Firestore Pipelines is currently in preview and is subject to potential breaking changes in future versions, | ||
| // regardless of any other documented package stability guarantees. | ||
| Snippet(query string) Expression |
There was a problem hiding this comment.
Are Snippet/Matches working? I thought they were pushed to after Next
|
|
||
| optionsPb := make(map[string]*pb.Value) | ||
|
|
||
| for k, v := range s.options { |
There was a problem hiding this comment.
IIRC search has some other options available (limit, select, query_enhancement, language_code). Have you checked if they are still in scope?
There was a problem hiding this comment.
Adding these does not return any errors while testing. Saw only one limitation that select supports only score.
@MarkDuckworth, are they still in scope?
There was a problem hiding this comment.
The only features exposed in the (java, node, iOS, Android, and Web) SDKs for the launch are:
Search stage:
- query
- sort
- addFields
Expressions:
- documentMatches(query)
- field(name).geoDistance(point) / geoDistance(field, point)
- score()
My understanding is that the backend now also supports:
- offset
- limit
- languageCode
- retrievalDepth
These will be a fast follow for the Java, Node, iOS, Android, and Web SDKs, so IMO it's okay to include them in the initial release for Go and Python.
TEsts were missing for those. After adding, found out that they are not supported. Removed them. |
Summary
This PR implements the
searchpipeline stage and its associated expressions in the Go Firestore SDK, providing parity with the Java (googleapis/java-firestore#2346) and Node.js (googleapis/google-cloud-node#7824) SDKs for full-text and geospatial search capabilities within Firestore Pipelines.Key Changes
Searchstage inPipelinewith a functional options pattern.WithSearchQuery,WithSearchSort,WithSearchAddFields, andWithSearchRetrievalDepthoptions.querywithin theOptionsmap (notArgs) to align with backend requirements and the Java SDK implementation.DocumentMatches(query string)andMatches(field, query string)for full-text search.GeoDistance(field, location)for geospatial distance calculations.Score()to retrieve the search topicality score.Snippet(field, query)for highlighted search result snippets.GeoDistance(location),Matches(query), andSnippet(query)methods to theExpressioninterface to support fluent chaining (e.g.,FieldOf("location").GeoDistance(loc)).pipeline_test.goandpipeline_function_test.go.Usage Example