So I created a new custom field for Account called Total Potential Revenue of type Currency. But when I click on the field name to sort the data, it shows an "up and down arrow" like sorting but the data is not sorted. I tried changing the data type to Number or Floating point number but still unable to sort the data. Is there any way to fix this? Thanks in advance.
Your RetrieveMultiple plugin needs to handle the sorting. CRM is passing the sort expression to the database which doesn't have any data to sort which is why you're getting what seems like a nonsensical order.
Your plugin should pull the order expressions out of the request (if the query was a QueryExpression, for example, the order expressions are found in the queryExpression.Orders collection) and then sort your results accordingly before returning the collection.
Related
I'm looking to sort a list based on most closely matching to a query. So for my case, I have a custom object called movie, which has several fields, the one I'm concerned with is title. When I do the search, the OMDb API returns some results but unfortunately, the API's results are a little wonky sometimes in the way they're sorted.
For instance, searching "Guard" returns "The Old Guard" first, even before movies titled "Guard" and "The Guard". So what I'm looking to do is take the query string, in this case "guard", and sort the list of movie results based on how closely movie.title matches the query. I'm using an ArrayList to store these objects. Thanks for any help.
Right now i'm trying to solve the problem where a calculated field for each object in a set of objects is dependent on input from the client and the results need to be sorted by this calculated field.
I know it is easily solvable using SQL, but let's say the query results are dependent on multiple external API's and calculated fields are dependent on the results of these API requests. How would the client be able to sort these query results using one of the available calculated fields?
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.
I am using jqgrid Advanced Search functionality in my project. I want to display the first overall row at all times irrespective of search. Is there a way how I can achieve this?
What do you mean by first overall row?
Are you fetching details from a list or from a database?
You can use a Dataprovider object and use it's setSort method..
If the data is coming from a database this can easily be done by using the sort property to pass it as the sort by property in your sql statement, if you're using a list you can use Collections.sort() but your list object has to have a sorting algo that it should follow..
I got my lucene index with a field that needs to be sorted on.
I have my query and I can make my Sort object.
If I understand right from the javadoc I should be able to do query.SetSort(). But there seems to be no such method...
Sure I'm missing something vital.
Any suggestions?
There are actually two important points. First, the field must be indexed. Second, pass the Sort object into the overloaded search method.
Last time I looked, the docs didn't do a very good job of pointing out the indexing part, and certainly didn't explain why this is so. It took some digging to find out why.
When a field is sortable, the searcher creates an array with one element for each document in the index. It uses information from the term index to populate this array so that it can perform sorting very quickly. If you have a lot of documents, it can use a lot of memory, so don't make a field sortable unless there is a need.
One more caveat: a sortable field must have no more than one value stored in each field. If there are multiple values, Lucene doesn't know which to use as the sort key.
It looks like the actual method you want is e.g. Searcher.search(Query query, Filter filter, int n, Sort sort). setSort is a method of Sort.