[DEPRECATED] Search
Warning
This article promotes customizations
, listings
and people
GraphQL queries, which are deprecated due to the limited configuration option. To leverage the power of ElasticSearch, we recommend using JSON Documents, which allows you to define your own ElasticSearch mapping and have full control on what gets stored in the ElasticSearch.
In platformOS, we support searching and filtering using Elasticsearch.
Search is usually more complex than other GraphQL queries because of the many additional filters that you can choose from. You can build search for any object supported in GraphQL.
Elasticsearch indexes
The following GraphQL entry points are powered by the Elasticsearch index:
- Customizations
- Listings
- People
Each property has two corresponding fields in the Elasticsearch index:
- The first field gets analyzed (tokenized) during document creation/update, and might be different than the origin.
- The second field is unchanged (
.raw
).
Examples:
raw | tokenized |
---|---|
www.platform-os.com |
www.platform os.com |
[email protected] |
darek near me.com |
word.other,another |
word other another |
`word | other |
The raw field data is used mostly for both exact filtering and sorting while the analyzed field is used for full text searching (query).
In most cases, you don't have to specify which field to use - it's automated and based on operation type. But you can explicitly point out which field to be used by appending the .raw
postfix to the field name:
{
customizations(
query: {
keyword: "example"
fields: [
{ name: "properties.title.raw", priority: 1 }
]
}
){
results {
title: property(name: "title")
}
}
}
Keyword search
By default keyword search is looking in all fields that are provided to the database. Use query
if you want to do a full-text search for a keyword. It does a full-text search across all analyzed (tokenized) fields.
In your GraphQL query, you can narrow the field list by adding parameter fields.
If you leave the keyword field empty, it means you are looking for everything, so narrowing by field names will not be applied.
Learn more about narrowing keyword search in our Narrowing Keyword Search topic.
Example:
{
customizations(
query: {
keyword: "example"
fields: [
{ name: "properties.summary", priority: 1 }
{ name: "properties.bio", priority: 3 }
]
}
){
results {
name
summary: property(name: "summary")
bio: property(name: "bio")
}
}
}
Keyword match type
Search by default tries to match the keyword exactly with the words in the field. When you search for alan
it will match values alan
but also Mike Alan
and Mike Alan and Tommy
. You can also define keyword to match words that start or end with the specified phrase.
Learn more about keyword match type in our Keyword Match Type topic.