diff --git a/docs/API/search.md b/docs/API/search.md index a19d46ed..dc686526 100644 --- a/docs/API/search.md +++ b/docs/API/search.md @@ -17,7 +17,7 @@ You can use the search engine via the `GET /api/v1/search` endpoint to search th | aggregate_by[] | array | Fields to aggregate results. The expected format: `aggregate_by[]=name&aggregate_by[]=slug` | | aggregate_by_numeric[] | array | Fields to aggregate results by numeric values. The expected format: `aggregate_by_numeric[]=price&aggregate_by_numeric[]=count` | | filters[] | array | Filter by object properties. The expected format: `filters[propertyName]=value1&filters[propertyName2]=value2`. Follows the rules of the [ElasticSearch Query String Query](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html). | - | geo_filters | array | Filter by object geolocation properties. Example value: `geo_distance,1.50km,40.1,-19.2` which means: `filter name`, `distance`, `latitude`, `longitude`. For more information see [ElasticSearch docs](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-distance-query.html). Only `geo_distance` query is supported. | + | geo_filters | array | Filter by object geolocation properties. Example value: `geo_distance,1.50km,40.1,-19.2` which means: `filter name`, `distance`, `latitude` and `longitude`. For more information see [ElasticSearch docs](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-distance-query.html). Only the `geo_distance` query is supported. | | post_filters | array | Filter by object properties. Use it when you want aggregated counts without filters applied. Expected format: `filters[propertyName]=value1&filters[propertyName2]=value2` | | fields[] | array | List of content fields to be searched. The expected format: `fields[]=field1&fields[]=field2` | | order_by | string | Name of the field to sort results by (they are always primarily sorted by `_score`) | @@ -74,15 +74,27 @@ Response: ## Limit the search to a specific Content Type -You can easily limit the search to a specific Content Type by providing its name in `content_type[]` argument. +You can easily limit the search to a specific Content Type by providing its name in the `content_type[]` argument. + +## Order by content field + +You can sort the results from the search endpoint by Content Type's field using an "order_by" parameter: + +!!! Example + GET https://api.flotiq.com/api/v1/search?q=Flotiq&content_type[]=post&**order_by=date** + +Keep in mind that ordering by a field that is nested in the `object` input type (list) is not possible. + +!!! Note + You may also use the `.keyword` suffix for other data than text fields, for example, if you are using an `id` field that uses a `number` type in Flotiq, you may still want to consider using the `.keyword` suffix when ordering by such field. This will result in slightly faster searching and will sort objects by id alphabetically, not from the highest number to the lowest. ## Limit the search to a specific field -You can restrict querying to a specific field by passing the `fields[]` argument, for example `fields[]=name` would only search in the `name` field. +You can restrict queries to a specific field by passing the `fields[]` argument, for example, `fields[]=name` would only search in the `name` field. ## Increase scoring for specific fields -If you'd like to search in several fields but give better score to results that match the query in a specific field - you can use [ElasticSearch's field boosting](https://www.elastic.co/guide/en/elasticsearch/reference/7.6/query-dsl-query-string-query.html#query-string-multi-field) to promote fields. In order to do that - pass the fields and their weights through the `fields[]` argument, for example `fields[]=title^3&fields[]=content^1` would assign a weight of 3 to the `title` field and a weight of 1 to `content` field. +If you'd like to search in several fields but give better score to results that match the query in a specific field - you can use [ElasticSearch's field boosting](https://www.elastic.co/guide/en/elasticsearch/reference/7.6/query-dsl-query-string-query.html#query-string-multi-field) to promote fields. In order to do that - pass the fields and their weights through the `fields[]` argument, for example, `fields[]=title^3&fields[]=content^1` would assign a weight of 3 to the `title` field and a weight of 1 to the `content` field. ## Aggregate results by field @@ -90,7 +102,7 @@ If you'd like to display faceted results of your searches you can use the `aggre ## Get random content objects -You can use the `random_seed` parameter to retrieve random content objects. The `random_seed` parameter accepts a number value for a random number generator. This will sort data in random order, so if you want for example to retrieve two random content objects, you can pass any number to `random_seed` and set `limit` parameter value to 2. +You can use the `random_seed` parameter to retrieve random content objects. The `random_seed` parameter accepts a number value for a random number generator. This will sort data in random order, so if you want for example to retrieve two random content objects, you can pass any number to `random_seed` and set the `limit` parameter value to 2. !!! Note Since random_seed is changing the order of retrieved content objects, it will override the value of your `order_by` parameter. diff --git a/docs/Deep-Dives/storing-location-data-headless-cms.md b/docs/Deep-Dives/storing-location-data-headless-cms.md index 61badcc3..72abb946 100644 --- a/docs/Deep-Dives/storing-location-data-headless-cms.md +++ b/docs/Deep-Dives/storing-location-data-headless-cms.md @@ -3,7 +3,7 @@ description: This tutorial shows how to build a store locator webpage using Flot # Storing location data -Flotiq plays really well with location data, especially once you get to use our search capabilities. In this quick tutorial we'll build a very simple web page that displays locations on a map and allows to easily search your location database. +Flotiq plays really well with location data, especially once you get to use our search capabilities. In this quick tutorial, we'll build a very simple web page that displays locations on a map and allows you to easily search your location database. What we'll need: @@ -13,14 +13,14 @@ What we'll need: - A scoped API key - Some HTML, CSS and plain Javascript (to keep things simple). -And here's a sneak peak at what we'll build. +And here's a sneak peek at what we'll build. ![Flotiq-based store locator](images/store-locator-1.png){: .center .border .width75} ## Setting up Flotiq -Once you [registered a Flotiq account](https://editor.flotiq.com/register.html) and logged in, you'll have to create a new Content Type Definition. This is how you tell Flotiq what kind of data you will be dealing with. Mine looks like this: +Once you [register a Flotiq account](https://editor.flotiq.com/register.html) and log in, you'll have to create a new Content Type Definition. This is how you tell Flotiq what kind of data you will be dealing with. Mine looks like this: ![Store Content Type Definition](images/store-locator-2.png){: .center .border .width75} @@ -30,7 +30,7 @@ Next - create several Content Objects under the `Store` type. I added 3 shops in ![Store entries in grid](images/store-locator-3.png){: .center .border .width75} -Finally - setup a scoped API key - you'll need it in a moment. +Finally - set up a scoped API key - you'll need it in a moment. ## Building the page @@ -180,7 +180,7 @@ You will need to populate the `TOKEN` constant with your API key, copied from Fl { data-search-exclude } !!! warning - We strongly recommend to create a dedicated key for every application you build and explicitly define the access scope to cover only the least amount of privileges required for a given app. Read more about [Flotiq's scoped API keys](https://flotiq.com/docs/API/#user-defined-api-keys) in our docs. + We strongly recommend creating a dedicated key for every application you build and explicitly defining the access scope to cover only the least amount of privileges required for a given app. Read more about [Flotiq's scoped API keys](https://flotiq.com/docs/API/#user-defined-api-keys) in our docs. Now, define the `loadMarkers()` function, like this: @@ -449,7 +449,7 @@ A neat, yellow box with a positioning icon should appear in your browser: ![Browser location can be used to navigate the map](images/store-locator-6.png){: .center .border .width75} -Let's now add an input field and connect the geocodeing service to translate location names to coordinates. +Let's now add an input field and connect the geocoding service to translate location names to coordinates. Add a text input to the yellow overlay: ``` @@ -502,7 +502,7 @@ Now, let's add an event handler on the form's submit event. Once a user submits ``` { data-search-exclude } -You can now put cities or full addresses in the text input. When you submit the form - your map should automatically move to the address you entered and the nearby stores should load. +You can now put cities or full addresses in the text input. When you submit the form - your map should automatically move to the address you entered and the nearby stores should load. ## Final touches @@ -539,7 +539,7 @@ with ``` { data-search-exclude } -This should provide standard maps popovers, if you'd like to give them some extra style - add this to the CSS file and adjust to your needs: +This should provide standard maps popovers if you'd like to give them some extra style - add this to the CSS file and adjust to your needs: ``` .leaflet-popup-content-wrapper { @@ -637,6 +637,6 @@ and finally - drop this at the end of the `onMarkersLoaded()` function: ``` { data-search-exclude } -That's it! You should now have a fully working webpage, which will display the list of stores you store in Flotiq and will place the store's on a map. Look into our [Git repository](https://github.com/flotiq/flotiq-demo-storing-location-data) for some extra style and let us know in the comments when you build something! +That's it! You should now have a fully working webpage, which will display the list of stores you store in Flotiq and will place the stores on a map. Look into our [Git repository](https://github.com/flotiq/flotiq-demo-storing-location-data) for some extra style and let us know in the comments when you build something! ![The final result - store locator webpage with data dynamically pulled from Flotiq](images/store-locator-7.png){: .center .border .width75} diff --git a/docs/panel/webhooks/hosted-webhook.md b/docs/panel/webhooks/hosted-webhook.md index 08b29837..fda247af 100644 --- a/docs/panel/webhooks/hosted-webhook.md +++ b/docs/panel/webhooks/hosted-webhook.md @@ -18,7 +18,7 @@ Example Use Cases: ## Setting Up Hosted Sync Webhooks -Creating a Hosted Sync Webhook follows a similar process as for sync webhooks. Once you select the type of your webhook to "synchronous", you will be presented with radio option, allowing you to choose between a standard URL webhook or hosted webhook. +Creating a Hosted Sync Webhook follows a similar process as for sync webhooks. Once you select the type of your webhook to "synchronous", you will be presented with a radio option, allowing you to choose between a standard URL webhook or hosted webhook. Once you choose the "Code" option, an embedded code editor will show up, allowing you to easily write code for your hosted webhook without the need for the use of any IDE. The editor will contain example code snippets; one of which allows you to validate the target content object, and the second example that will mutate the content object, automatically creating a slug from the title property. @@ -52,7 +52,7 @@ function _webhook(ctx) { ``` { data-search-exclude } -This hosted webhok could be used to easily increment the number of the posts, when duplicating existing objects, or counting the number of edits on an event. +This hosted webhook could be used to easily increment the number of posts when duplicating existing objects, or counting the number of edits on an event. ### Generating a Slug