modernistik / parse-stack

Parse Server Ruby Client SDK
https://www.modernistik.com/gems/parse-stack/
MIT License
60 stars 20 forks source link

Support $text operator for full text search on index fields. #46

Closed apersaud closed 6 years ago

apersaud commented 6 years ago

Support for full text search starting with Parse-Server 2.5.0: For efficient search capabilities use the $text operator. By creating indexes on one or more columns your strings are turned into tokens for full text search functionality.

The format {"$text": {"$search": {parameters}}}

Parameter Use
$term Specify a field to search (Required)
$language Determines the list of stop words and the rules for tokenizer.
$caseSensitive Enable or disable case sensitive search.
$diacriticSensitive Enable or disable diacritic sensitive search

From the documentation:

# Finds strings that contains "Daddy"
curl -X GET \
  -H "X-Parse-Application-Id: ${APPLICATION_ID}" \
  -H "X-Parse-REST-API-Key: ${REST_API_KEY}" \
  -G \
  --data-urlencode 'where={"name":{"$text":{"$search":{"$term":"Daddy"}}}}' \
  https://api.parse.com/1/classes/BarbecueSauce
# Finds strings that contains "Daddy" ordered by relevance
curl -X GET \
  -H "X-Parse-Application-Id: ${APPLICATION_ID}" \
  -H "X-Parse-REST-API-Key: ${REST_API_KEY}" \
  -G \
  --data-urlencode 'where={"name":{"$text":{"$search":{"$term":"Daddy"}}}}' \
  --data-urlencode 'order="$score"' \
  --data-urlencode 'key="$score"' \
  https://api.parse.com/1/classes/BarbecueSauce

https://docs.parseplatform.org/rest/guide/#queries-on-string-values