Solr 7.3 - Sort conditionally on multi-valued field - sorting

I am new to Solr, using Solr 7.3 and I am trying to achieve the following - given a date, I need to retrieve all products which have contracts expiring beyond this date, sorted on the earliest expiring contract, but not considering the already expired contracts. I am not able to get the sort correct. In the below case, product_id "10002023" should have been the last in the list as it has a contract which is expiring last (2021-08-31), ignoring the already expired contract. Any help is greatly appreciated.
http://localhost/solr/catalogue/select?fl=product_id,%20contract_id,%20contract_valid_to&fq=contract_id:[*%20TO%20*]&fq=contract_valid_to:%20[2018-12-12%20TO%20*]&q=*:*&sort=field(contract_valid_to,%20min)%20asc
..."docs":[
{
"product_id":"10002023",
"contract_id":["1427",
"1428"],
"contract_valid_to":["2018-12-07 15:36:13.0",
"2021-08-31 15:40:33.0"]},
{
"product_id":"1012974",
"contract_id":["867"],
"contract_valid_to":["2019-05-16 15:58:01.0"]},
{
"product_id":"1012985",
"contract_id":["777"],
"contract_valid_to":["2019-05-19 11:07:50.0"]},
{
"product_id":"1012975",
"contract_id":["787"],
"contract_valid_to":["2019-05-24 12:02:18.0"]},
{
"product_id":"1012997",
"contract_id":["831"],
"contract_valid_to":["2019-05-29 15:37:37.0"]}]

Unfortunately, the definition that you're using for date field is incorrect
<dynamicField name="contract_*" type="string" multiValued="true" indexed="true" stored="true"/>
It is assuming that this is just a plain string, not different from anything else.
Also, regarding your second comment Solr supports dates of only 1 format - YYYY-MM-DDThh:mm:ssZ, so if you want to use date features you would need to do conversion to a proper format and use date type.

Related

Query on Ali baba Cloud Billing API BOA

I was trying to get some data by using one of the api call QueryInstanceBill
The resulted JSON seems to be long and there is no date column to filter on how i got those many records.
Could someone here help me out
To be able to filter by date, The billing date only used when Granularity is DAILY,format: YYYY-MM-DD. Example 2020-07-29
You can also use the "BillingCycle" field in the request:
The billing cycle. Format: YYYY-MM. Example: 2020-07
Documentation:
https://www.alibabacloud.com/help/doc-detail/100400.htm
QueryInstanceBill API returns data for billing cycle which is usually for a month (YYYY-MM)
If you want data for a particular date then in request parameter provide the value for field "BillingDate" in format: YYYY-MM-DD
and the value for field "Granularity" should be "DAILY"
Check out the documentation:
https://www.alibabacloud.com/help/doc-detail/100400.htm
Also, you can use OpenAPI Explorer, I have provided BillingCycle as "2019-10", BillingDate as "2019-10-15" and Granularity as "DAILY":
https://api.aliyun.com/#/?product=BssOpenApi&version=2017-12-14&api=QueryInstanceBill&params={%22RegionId%22:%22cn-hangzhou%22,%22Granularity%22:%22DAILY%22,%22BillingCycle%22:%222019-10%22,%22BillingDate%22:%222019-10-15%22}&tab=DEMO&lang=JAVA

Microsoft Graph API: Filter messages received last month

I was wondering if Microsoft Graph has filtering available to retrieve emails only received last month that is from 1st day of last month to last day of last month.
Also, I save custom user properties with each email called "CompletedTime". I would also like to know if there is any filtering which would only pull emails which has value in custom user property "CompletedTime".
Thank you in advance.
KQL has a reserved keyword for last month https://learn.microsoft.com/en-us/sharepoint/dev/general-development/keyword-query-language-kql-syntax-reference so something like
https://graph.microsoft.com/v1.0/me/messages?$search="received:\"last month\""&$select=subject,receivedDateTime&$Top=1000
Should work to return the last months email, you could also do a filter or a search using a date range.
Also, I save custom user properties with each email called "CompletedTime". I would also like to know if there is any filtering which would only pull emails which has value in custom user property "CompletedTime".
If you know what the extended property representation of the property is then you can use a Filter on that. (If you don't know what the extended property is then use a MAPI editor like OutlookSpy of mfcmapi to work it out.

Trying to return the maximum value of a filtered date column in Power BI

I have a table within Power BI that has a date field, and a value field. I am filtering on this date field, using a slicer, to sum all of the value data before the specified date. I would like to get this date value to use in a LOOKUPVALUE() elsewhere (to get a conversion rate).
Is there a way to accomplish this?
I have tried the DAX functions that return the values of a particular table/column with filters preserved but this never seems to work, and just returns the entire dataset, e.g. VALUES(), FILTERS(), ALLEXCEPT().
Any help would be greatly appreciated!
I found a solution using measures.
The DAX for future reference:
Filter Date = CALCULATE(MAX('Table'[Date]),ALLSELECTED('Table'))

Google People API, return last modified date?

Is there a way to retrieve the last modified timestamp for this endpoint GET https://people.googleapis.com/v1/{resourceName=people/*}/connections
I am unable to see anything close to resembling this in the Person object fields described here https://developers.google.com/people/api/rest/v1/people#Person
Recently an updateTime was added to the Source field https://developers.google.com/people/api/rest/v1/people#Person.Source.
You can get it by iterating over the person.metadata.sources

iReports Grouping Bug - Multiple Occurrences?

I'm am getting irritated with iReports. Problem is that I have a data set returning data for multiple customers and I want to use the "Group Expression" against the customer ID and have the report lay out the Detail Tabs per customer.
I'm finding that, seeming randomly, where there is more that one data row for a customer iReports will generate two or more groupings (Sometimes it does what I expect and group all the customer data together), the field IDing the customer is the same and doesn't change.
Has anyone seen this before? To be honest I can't believe it is actually a bug, but something I've missed. Just much searching as yet to find a suitable result.
I think this is a data sorting problem.
The quote from iReport Ultimate Guide:
JasperReports groups records by evaluating the group expression. Every
time the expression's value changes, a new group instance is created.
The engine does not perform any record sorting (if not explicitly
requested), so when we define groups we should always take care of the
records sorting. That is, if we want to group a set of addresses by
country, the records we select for the report should already by
ordered by country. It is simple to sort data when using an SQL query
by using the ORDER BY clause. When this is not possible (that is, when
obtaining the records from an XML document), we can request that
JasperReports sort the data for us. This can be done using the sort
options available in the query window
You can sort data in these ways:
in case using of Database jdbc connection datasource type you can add ORDER BY customerId clause to the report's query, where customerId - column name of field with customer id
in case using of File csv connection or something like this you can organize data sorting by adding sortField property for field to the report's template (jrxml file):
<jasperReport ...>
...
<field name="customerId" class="java.lang.String"/>
<sortField name="customerId"/>
SQL Statement has ORDER BY?
iReport group is grouped by customer_id?

Resources