fix: combine space-separated terms with & operator in free-text search #387
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There is some ambiguity between the free-text STAC API extension and the OGC Records specification (stac-api-extensions/freetext-search#12), so I am not 100% sure this is the right thing to do, but right now if you pass a string with two terms separated by spaces (but not quoted), pgstac will throw a tsquery syntax error (https://github.com/stac-utils/pgstac/actions/runs/18101825325/job/51506541624).
From the OGC Records Spec:
This PR replaces spaces with
&
which I think is the behavior that most closely aligns with the specification but does not account for the order of the terms like the spec suggests. I tried using distance operators (e.g.<10>
) but that checks for an exact distance between terms ("distance equals 10") instead of checking for "less than or equal to 10".