Solr - need the boosting within the sort param - sorting

I have a list of docs of solr which would be having 2 fields groupId and assetId. What I want is that the sequence of the list should be all groupId docs together and within that, it should be placed according to the assetId no. This scenario is easily available by modifying sort param.
sort=groupId asc,assetId asc
But what I want next is, few groupId s should be boosted and shown first.
So my question is how to mention this in sort param, i.e. boosting some of the groupids, compared to others. and each groupId section would be internally ordered based on assetId value.
Through Example:
Data in Solr:
GroupId AssetId
1 A
2 A
1 C
1 B
3 C
3 B
2 C
3 A
2 B
So
sort=groupId asc,assetId asc
would result into
GroupId AssetId
1 A
1 B
1 C
2 A
2 B
2 C
3 A
3 B
3 C
while what I require is groupId 3 and 1 should be boosted to show them before 2. Ordering within each of the groupId 3 , 1, and 2 should be assetId.
GroupId AssetId
3 A
3 B
3 C
1 A
1 B
1 C
2 A
2 B
2 C
FYI, I am using Solr with Liferay and groupId that needs to be boosted is a dynamic number i.e. it depends on the user currently logged into the liferay. Is it possible to mention boosting in anyway in sort param to specify which value of the sort field are more important?

I had resolved this problem at that time. I used function query concept of Solr in sort param. query({!v="3,1"})
Conceptually, it was like below where 3 and 1 are my groupId's that are required to be above the rest of the groupId. Since we have added two other sort params groupId and assetId, it will basically boost these two groupIds and then within each groupId, it would further sort on assetId.
sort=query({!v="groupId:3^10.0 groupId:1^5.0"}) desc, groupId asc,assetId asc
Note: I don't remember the exact syntaxes. So please dig into the function query concept and get the exact syntax.

Related

Filter not-matching pivot table documents in Elasticsearch

We have a database replicated in Elasticsearch (...). Given the following ...
Service
id
name
1
service1
2
service2
3
service3
Package
id
name
1
package1
2
package2
PackageService (pivot)
id
PackageId
ServiceId
1
1
1
2
1
2
3
2
1
4
2
3
I want to return documents where "Packages reference only these services - excluding all packages that match anything else".
As an example, when I query PackageService with
{
bool
must
term
ServiceId [1, 2]
}
I get back package1 and package2. I don't want package2, because while it does reference service1, it also references service3.
The solution I've come up with is to run two queries. One as above, and another inverted, like
{
bool
must_not
term
ServiceId [1, 2]
}
and then array_diff (php) the two results array_diff([1, 2], [1]) => [1], which is what I want.
Is there any way to do this with one query?
Note, I do not know about service3 when I am making the queries, so I cannot simply include it in a must_not.

How to filter a column according to values of another column in Tableau

Suppose that my query is 'A' for the following table. I want to find any value of 'c_index' corresponding to 'A', and then get all the rows of the table which have the corresponding values of 'c_index'.
Node Name
c_index
A
1
B
1
A
2
C
2
B
3
D
3
C
4
E
4
Values of 'c_index' corresponding to 'A' are {1, 2}. So the desired result of the filter is:
Node Name
c_index
A
1
B
1
A
2
C
2
How can I do this filtration in Tableau?
What I tried is:
Defined a filter on 'c_index' (i.e. drag and drop 'c_index' to the filter shelf). And then I tried to define the condition for the filter as: [Node Name] = 'A'.
But it throws an error: "The formula must be an aggregate calculation or refer only to this field".
First Join the (data) table with itself on the column which you want to return linked values. In the example c_index.
Now there will two same data sets in your data pane.
Add node from first dataset to filter, node from second dataset to view and c_index from anyone to view. You'll get what you desire. See GIF below

SUMIF with date range for specific column

I've been trying to find an answer for this, but haven't succeeded - I need to sum a column for a specified date range, as long as my rowname matches the reference sheet's column name.
i.e
Reference_Sheet
Date John Matt
07/01/19 1 2
07/02/19 1 2
07/03/19 2 1
07/04/19 1 1
07/05/19 3 3
07/06/19 1 2
07/07/19 1 1
07/08/19 5 9
07/09/19 9 2
Sheet1
A B
1 07/01
2 07/07
3 Week1
4 John 10
5 Matt 12
Have to work in google sheets, and I tried using SUMPRODUCT which told me I can't multiply texts and I tried SUMIFS which let me know I can't have different array arguments - failed efforts were similar to below,
=SUMIFS('Reference_Sheet'!B2:AO1000,'Reference_Sheet'!A1:AO1,"=A4",'Reference_Sheet'!A2:A1000,">=B1",'Reference_Sheet'!A2:A1000,"<=B2")
=SUMPRODUCT(('Reference_Sheet'!$A$2:$AO$1000)*('Reference_Sheet'!$A$2:$A$1000>=B$1)*('Reference_Sheet'!$A$2:$A$1000<=B$2)*('Reference_Sheet'!$A$1:$AO$1=$A4))
This might work:
=sumifs(indirect("Reference_Sheet!"&address(2,match(A4,Reference_Sheet!A$1:AO$1,0))&":"&address(100,match(A4,Reference_Sheet!A$1:AO$1,0))),Reference_Sheet!A$2:A$100,">="&B$1,Reference_Sheet!A$2:A$100,"<="&B$2)
But you'll need to specify how many rows down you need it to go. In my formula, it looks down till 100 rows.
To change the number of rows, you need to change the number in three places:
&address(100
Reference_Sheet!A$2:A$100," ... in two places
To briefly explain what is going on:
look for the person's name in row 1 using match
Use address and indirect to build the address of cells to add
and then sumIfs() based on dates.
alternative:
=SUMPRODUCT(QUERY(TRANSPOSE(QUERY($A:$D,
"where A >= date '"&TEXT(F$1, "yyyy-mm-dd")&"'
and A <= date '"&TEXT(F$2, "yyyy-mm-dd")&"'", 1)),
"where Col1 = '"&$E4&"'", 0))

SSRS Reporting - count number of group rows

I am trying to the count of number of groups in my report I know I could do it in the SQL however trying to avoid adding redundant data to my dataset if I can.
I have a MainDataSet that could have multiple entries per distinct group item. All I want is the no. of groups not the count of items within the group.
For example words starting with alphabet letters, lets say I have 2 groups A and B only (NB: number of groups can change dynamically as I filter the MainDataSet based on user parameter selection):
Group | Data
------|-----
A | Apple
A | Ant
B | Balloon
B | Book
B | Bowl
Final Result:
Group | Index | NGroups
A | 1 | 2
B | 2 | 2
I know I can get the Index using a aggregate function as follows:
RunningValue(Fields!Group.Value, CountDistinct, "TablixName")
But how do I get the NGroups value?
I guess I could also create another dataset based on the MainDataSet (make use of a sql function) and do:
SELECT 'X' AS GroupCount, COUNT(Distinct Group) AS NGroups
FROM dbo.udf_MainDataSet()
WHERE FieldX = #Parameter1
Then use a LookUp:
Lookup("X", Fields!GroupCount.Value, Fields!NGroups.Value, "NewDataSet")
But is there a simple solution that I am not seeing?
CountDistinct(Fields!Group.Value, "TablixName")

Group on sum of distinct values in Tableau

I'm using Tableau 8.3 and i'm trying to find out how to group on each of the values that I find after making a "count of distinct values".
To illustrate the case I have made a fictive dataset which includes 58 rows (buys), 7 different IDs (customers) and 5 different products. Then I have made a count distinct to find out how many of the 5 different products each ID have bought. It looks like this.
ID1 = 4
ID2 = 4
ID3 = 5
ID4 = 4
ID5 = 3
ID6 = 4
ID7 = 2
Now I want to turn the view around and find out how many of the IDs who have bought X different products. It should ultimately look like this.
2 = 1
3 = 1
4 = 4
5 = 1
Hope to find a solution by posting here! Thank you,
Mikael
You need to update to Tableau 9.0 to achieve that (in a fast way).
You can create a calculated field named #of products:
{ FIXED [id_customer] : COUNTD([id_product]) }
Then you can cross the [# of products] with COUNTD(id_customer) to get what you want.
In older versions of Tableau you need to create a new table in a proper format (1 line per customer with the aggregations) and connect to it.

Resources