Sorting string column in Kibana visualization - elasticsearch

I have a status field in my elastic search index which can take values Open,Closed,Clear,Intermediate,Ready for Approval. Right now, I have created a visualization and sorted this field descending based on the Term. What I want to achieve is - I want this to be sorted in this particular order Open,Clear,Intermediate,Ready for Approval,Closed.
How do I achieve this? One option I am thinking is creating a scripted field and prefixing with integer column, but I am not sure if I will be able to filter the visualization later?

If this list of possible values is a static list of known values, there is another way to define your visualization with a little more manual configuration. Just replace your terms aggregation with a filters aggregation and add custom filters for the possible values like so:
Kibana will respect the order of your filters in the visualization. From a performance perspective, this should also be better than using a scripted field...

Related

Elastic Search and Search Ranking Models

I am new to Elastic Search. I would like to know if the following steps are how typically people use ES to build a search engine.
Use Elastic Search to get a list of qualified documents/results based on a user's input.
Build and use a search ranking model to sort this list.
Use this sorted list as the output of the search engine to the user.
I would probably add a few steps
Think about your information model.
What kinds of documents are you indexing?
What are the important fields and what field types are they?
What fields should be shown in the search result?
All this becomes part of your mapping
Index documents
Are the underlying data changing or can you index it just once?
How are you detecting new docuemtns/deletes/updates?
This will be included in your connetors, that can be set up in multiple ways, for example using the Documents API
A bit of trial and error to sort out your ranking model
Depending on your use case, the default ranking may be enough.
have a look at the Search API to try out different ranking.
Use the search result list to present the results to the end user

How can I create a list of values for a field in Kibana?

I am using Kibana to view data from Elasticsearch index. There is a field only has a few values. When I do search the field, how can I make the search bar as a select rather than a free text input? I know that there is a filter list like below image:
but it doesn't work for the case that top 5 values in 500 records have one value. How can I show all values in the history as a list for a field?
I think your are looking for "controls" visualization.
Go to visualization > controls
Then choose option list, your index and your field.
The result will be a dropdown with values like if you did a select distinct on your field within the whole kibana range.
Add it to a dashboard to have a filtering interface human usable dashboard.
Update:
Maybe a simple filter on the discover page can answer to your question.

How to sort (and give weight) by Availability dates in SolR

i'm facing a big problem in my SolR DB.
My objects have a datetime field "Available_From" and a datetime field "Available_To".
We also have a "Ranking" field for the sorting.
I can search correctly with direct queries (eg. give me all the items that are available at the moment) but when i do a regular search i cannot find a way to show the items that result "available NOW" in the first places in the results, usually sorted by "Ranking" field.
How can i do this? Am I forced to write some java classes (the nearest thing i've found is there https://medium.com/#devchaitu18/sorting-based-on-a-custom-function-in-solr-c94ddae99a12) or is there a way to do with standard SolR queries?
Thanks in advance to everyone!
In your case you actually don't want sorting, since that indicates that you want one field to determine the returned sequence of documents.
Instead, use boosting - apply a very large boost to those that are available now, either through bq or boost, then apply a boost based on ranking. You'll have to tweak the weights given to each part based on how you want the search results to be presented.

In ElasticSearch, how do I get only one from list in subproperties (nested/child/whatever) and sort by it

I have a type Product, which has multiple Prices, but the returned model can only ever have one price.
I need to have multiple prices in elastic, to be able to vary on time without having to reindex. I also need to be able to sort products based on price.
I have tried both with nested and child properties, but I don't seem to be able to query it correctly.
So is it possible to achieve this using elastic? If not, how should I structure my index instead?
You can set the field data type to array. Then sort by for example the max value using the mode option.
See for examples:
https://www.elastic.co/guide/en/elasticsearch/reference/current/array.html
https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-sort.html
What ended up doing is to get the current price via inner hits https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-inner-hits.html
And then add the inner hit to the model after it was returned from elastic.

Solr: Excluding certain documents from getting sorted

I have a Solr query where i am trying to sort the results based on a certain field.
I want to modify it in such a way that only a particular set of documents get sorted and the remaining are simply appended to the end of the sorted list.
Is there a way to achieve this?
Please help.
Regards.
If you want to Sort by a particular field condition which is dynamic, you can boost the field with matching condition higher and sort by score.
for e.g. bq=some_field:some_value^10
This will boost the scores of the documents only matching the criteria.
Also, for all the other documents the score would be unchanged and would follow the boasted documents as is.
EDIT :-
you can boost on multiple fields e.g. bq=string_array_field:some_value^10&bq=ranking^10 would boost the documents matching the value and the having higher ranking to the top.
The rest of the documents would follow.
For each <fieldType> definition in your schema.xml you can set a sortMissingLast="true" option that would give you the desired sorting behavior. For your specific example, I would recommend creating a new field with the sortMissingLast="true" set and use then populate this additional field based on your given criteria and not setting a value for those documents you want to appear at the end when sorted.

Resources