Sphinx multi value attribute filter - filter

Yes, each tag has unique Id. It is not necessary that I have to store these unique id's in a table. I can store them in this way…
$tags = array("Music","Sports","Food","Books",………)
Array is the best way for me as it is easily alterable. Moreover the array keys itself will serve as the unique Id's.
But my situation is more critical, so let me elaborate the exact situation.
I have a single table with fields like Id, Title, Description, Tags, etc. etc. etc.
Id | Title | Description | Tags
1 | Sport & Hygine| With sport & music good food is …| Sport, Food
2 | Rock Concert | Great Rock Show at … | Music, Dance
If a user selects (filter) to show records, that has Music in the Tags field. Although the Title and description does not have the word Music at all in the second row, but still it should get the first priority. Also it should be noted that Title and Description are text fields and Sphinx should search the normal way giving appropriate Weights and Ranks to Titles and Description. But Tags field cannot be searched as text indexing. Tags field needs to be filtered.
Therefore, in the above example, if Music is selected, then row 2 should only be displayed, because it is filtered based on Tags and Row 2 only has Music in the Tags field. But Music is also present in Row 1 in the Description field, but here it should be ignored. I hope I am able to clarify the situation. Any hep with this is highly appreciated.

The unique-id needs to be unique across all documents. So that "Sports" would have the same ID on all documents, and therefore the same ID can be used for searching. So you search for the ID, not the word.
So the tags can be used to influence ranking, you can put them in a Field. But ALSO store the tag-ids in a MVA, so can use for setFilter.
Something like
Music #tags Music
should work as an extended query. BEcause it requires the word Music in Tags. But also the first term will match all feilds and help with ranking.

Related

Google sheets drop down with extra description - not dynamic

I'm trying to create a drop down picker that shows a list of values, but actually stores a related value.
The list I'm working with looks like:
ID Desc
AA An option
AB Different option
B3 Some other option
So I want the user to see the description, but the value stored when they have picked one is the ID column.
I've search a lot but can only find either simple data validation or dymanic (Multiple dropdows based on a prior drop down)
My users won't remember the ID's, but by having the text descriptions they will find it easier.
Any help please?
Lots of searching for clues, but can only find either simple single column drop downs, or dynamic.
Lets say, you want to select description id D7 cell then want to show result from J Column as per ID of selected description. Then Try-
=XLOOKUP(XLOOKUP(D7,B2:B4,A2:A4),I2:I4,J2:J4)

DAX COUNT/COUNTA functions

I've looked at many threads regarding COUNT and COUNTA, but I can't seem to figure out how to use it correctly.
I am new to DAX and am learning my way around. I have attempted to look this up and have gotten a little ways to where I need to be but not exactly. I think I am confused about how to apply a filter.
Here's the situation:
Four separate queries used to generate the data in the report; but only need to use two for the DAX function (Products and Display).
I have three columns I need to filter by, as follows:
Customer (Display or Products query; can do either)
Brand (Products query)
Location (Display query)
I want to count the columns based on if the data is unique.
Here's an example:
Customer: Big Box Buy;
Item: Lego Big Blocks;
Brand: Lego;
Location: Toys;
BREAK
Customer: Big Box Buy;
Item: Lego Star Wars;
Brand: Lego;
Location: Toys;
BREAK
Customer: Big Box Buy;
Item: Surface Pro;
Brand: Microsoft;
Location: Electronics;
BREAK
Customer: Little Shop on the Corner;
Item: Red Bicycle;
Brand: Trek;
Location: Racks;
In this example, no matter the fact that the items are different, we want to look at just the customer, the brand, and the location. We see in the first two records, the customer is "Big Box Buy" and the brand is "Lego" and the location is "Toys". This appears twice, but I want to count it distinct as "1". The next "Big Box Buy" store has the brand "Microsoft" and the location is "Electronics". It appears once and only once, and thus the distinct count is "1" anyway. This means that there are two separate entries for "Big Box Buy", both with a count of 1. And lastly there is "Little Shop on the Corner" which appears just once and is counted just once.
The "skeleton" of the code I have is basically just to see if I can get a count to work at all, which I can. It's the FILTER that I think is the problem (not used in the below example) judging by other threads I've read.
TotalDisplays = CALCULATE(COUNTA(products[Brand]))
Obviously I can't just count the amount of times a brand appears as that would give me duplicates. I need it unique based on if the following conditions are met:
Customer must be the same
Brand must be the same
Location must be the same
If so, we distinctly count it as one.
I know I ranted a bit and may seem to have gone in circles, but I was trying to figure out how to explain it. Please let me know if I need to edit this post or post clarification.
Many thanks in advance as I go through my journey with DAX!
I believe I have the answer. I used a NATURALINNERJOIN in DAX to create a new, merged table since I needed to reference all values in the same query (couldn't figure out how to do it otherwise). I also created an "unique identity" calculated column that combined data from multiple rows, but was hidden behind the scenes (not actually displayed on the report) so I could then take a measure of the unique values that way.
TotalDisplays = COUNTROWS(DISTINCT('GD-DP-Merge'[DisplayCountCalcCol]))
My calculated column is as follows:
DisplayCountCalcCol = 'GD-DP-Merge'[CustID] & 'GD-DP-Merge'[Brand] & 'GD-DP-Merge'[Location] & 'GD-DP-Merge'[Order#]
So the measure TotalDisplays now reports back the distinct count of rows based on the unique value of the customer ID, the brand, and the location of the item. I also threw in an order number just in case.
Thanks!
I am semi new to DAX and was struggling with Count and CountA formula, you post has helped me with answers. I would like to add the solution which i got for my query: Wanted count for Right Time start Achieved hence if anyone is looking for this kind of answer use below, filter will be selecting the table and adding string which you want to
RTSA:=calculate(COUNTA([RTS]),VEO_Daily_Services[RTS]="RTSA")

Google Sheets For Filtered Drop Down

I have two sheets: CONTACTS and UPDATES.
On the CONTACTS sheet there are 2 columns: COMPANY and NAME. If I have 10 contacts at a company, then there will be 10 rows with the same company in column 1, and the names of the 10 people in column 2. Now of course there's a lot of companies and names on this list.
On the UPDATES page, column 1 is a drop down that lets me select the name of the company. In column 2 I want to have a pull down that filters and shows me only the people in the company that's in column 1.
I've searched quite a bit and while I have found things that are similar, none of the tips are quite right / work for my use case.
Is there an easy way to do this?
Thanks for your help!
You can use UNIQUE + FILTER to filter the results, but that won't give you the a dropdown. For a filtered dropdown, you can use the formula to get the filtered list and then use that as your range.
For example, in your CONTACTS tab, add a new column FilteredList, with this formula in the first row:
=unique(filter(B:B,A:A=E1))
where B:B is the NAME column, A:A is the COMPANY column and E1 is where you select the company name on the UPDATES page.
Now, instead of making the NAMES list as your valid entries, set it to FilteredList.

Repeating Table with Column From Secondary Source

I have been struggling with this all day. I have an Infopath form that is connected to two Sharepoint Lists.
SP List 1 (Project Charters):
Charter Title
Charter Opportunity
Charter Start Date
SP List 2 (Project Weekly):
Weekly Title
Weekly Opportunity.
I am attempting to combine these two lists into 1 repeating table on a new form. The Weekly Title field holds the same values as the Charter Title field, so I can match using Titles. I have found some resources, with this being the best:
http://www.infopathdev.com/forums/t/21262.aspx?PageIndex=2
There is a sample toward the end that does exactly what I want, but it will not work with my setup. Here is what I get:
As you can see in the picture, the "From my weeklys" column is always the same, and this is the problem. It should match with the corresponding field highlighted in red two the left. This is the formula in the calculated field:
Weekly_x0020_Opportunity[Weekly_x0020_Title = current()/Charter_x0020_Title]
The logic is to return the Weekly Opportunity description, where the Weekly Title matches the Charter Title; however, it only ever returns the same description. The testing column was used to prove that current()/Charter_x0020_Title was producing the unique titles for that row.
I feel like I am really close. The 3rd charter is missing a description, because my Weekly does not have a 3rd charter, so this is working properly. I just need to figure out how to bring-in the proper description.
Note: I am hoping for an Out-of-the-Box solution without coding.
FULL xPATH
xdXDocument:GetDOM("Project Weekly")/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:Weekly_x0020_Opportunity[xdXDocument:GetDOM("Project Weekly")/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:Weekly_x0020_Title = current()/d:Charter_x0020_Title]
The problem is that the path inside your predicate (between the []s) is using an absolute path rather than a relative one. You need to use a relative path.
This path (what you have now):
xdXDocument:GetDOM("Project Weekly")
/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:Weekly_x0020_Opportunity
[xdXDocument:GetDOM("Project Weekly")/dfs:myFields/dfs:dataFields
/d:SharePointListItem_RW/d:Weekly_x0020_Title = current()/d:Charter_x0020_Title]
means "Get the first1 Weekly Opportunity field where any Weekly Title field in the Project Weekly data source has the value of the current Charter Title."
Or in other words, get the first Weekly Opportunity field in the Project Weekly data source any time the stuff between the square brackets is true.
This path:
xdXDocument:GetDOM("Project Weekly")
/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW
[d:Weekly_x0020_Title = current()/d:Charter_x0020_Title]/d:Weekly_x0020_Opportunity
means "Find the first1 SharePointListItem_RW where its Weekly Title is equal to the current Charter Title, and then get its Weekly Opportunity field."
So that's what you should use.
1 I am oversimplifying a bit here by saying "first". That path selects all of the nodes where that path is applicable, and then when InfoPath evaluates it, it takes the first result.

How to properly organize search of the person?

Let's say I have list of persons in my datastore. Each person there may have the following fields:
last name (*)
first name
middle name
id (*)
driving licence id (*)
another id (*)
date of birth
region
place of birth
At least one of the fields marked with (*) must exist.
Now user provides me with the same list of fields (and again at least one of the fields marked with (*) must be provided). I should search for the person user provided. But not all fields should be matched. I should display to the user somehow how I am sure in the results of search. Something like:
if person matched by id and last name (and user provided just these 2 fields for the search), then I am sure that result is correct (100%);
if person matched by id and last name (and user provided other fields, which were found in the database, but were not matched), then I am sure that result is almost correct by 60%;
etc.
(numbers are provided just as example)
How can I organize such search? Is there any standard algorithm? I also would like to minimize number of requests to the database.
P.S. I can not provide user with the actual field values from the database.
It sounds like your logic for determining the quality of a match will be too complex to handle at the database layer. I think you'll get the best performance by retrieving all of the records that match at least one of the mandatory keys, calculating the match score for each of them in memory, and returning the best score. For example, if the user provides you with an id, last name and place of birth, your query would look something like:
SELECT * FROM users WHERE id = `the_id` OR last_name = `the_last_name`;
This could be a performance problem if you have a VERY large dataset with lots of common last names but otherwise I would expect not to see too many collisions. You can check this on your own dataset outside of GAE. You could also get better performance if all mandatory fields MUST match by changing the OR to an AND.

Resources