SharePoint 2013 KQL each query with xrank on multi value taxonomy field - search

In my search query I query for items which have a multi value taxonomy field.
The publishing page where I am running the query from also has the same multi value tax field (for example "color").
Example:
List Items (have color column)
- Item 1: Red, Blue
- Item 2: Yellow, Red, White
- Item 3: Red, Blue, Green
- Item 4: Black
Publishing Page (has color column)
- defined colors are: Red, Green
All items match "red", but "Item 3" is obviously my best match, as it has both Red and Green.
I need to return all items. I do not want to filter, I want to rank items.
First attempt: The following query returns all items.
However not each single value out of my multi value field is boosted but only the whole value altogether.
ContentTypeId:0x010600C0DEB45360CF4E9EB452AEFE3A238A1CA1* XRANK(cb=100) MyColorManagedProperty:{Page.MyColorColumn}
Problem:
For example Item 4 will have the same ranking as item 1 and 2. The boost of 100 will only apply to Item 3 (which has Red AND Green). I need a solution where Item 1 and 2 are treated higher than Item 4 as they at least contain "Red".
Update 1: (in a previous version I used a multi value choice field)
Technet: http://technet.microsoft.com/en-us/library/jj683123(v=office.15).aspx) - obviously multi choice fields are not supported. So in the meantime I switched to a multi value taxonomy field.
ContentTypeId:0x010600C0DEB45360CF4E9EB452AEFE3A238A1CA1* XRANK(cb=10) {|owstaxIdRsColor:{Page.RsColor}}
What I get is: XRANK (Property or Property or Property or ...)
What I want is: XRANK Property or XRANK Property or XRANK Property or ...`
Update 2:
Proper bracket placing works its wonders - so I thought. I tried to reproduce the desired result recently and failed miserably. I'm still looking for a solution. The approach below does NOT work.
ContentTypeId:0x010600C0DEB45360CF4E9EB452AEFE3A238A1CA1* XRANK(cb=100) (owstaxIdRsColor:{|{Page.RsColor}})
The result is: ContentTypeId:0x010600C0DEB45360CF4E9EB452AEFE3A238A1CA1* XRANK(cb=100) (owstaxIdRsColor:((#0655a6c23-6f73-43d4-b451-d01e0400717f) OR (#0de2d6451-8825-4c4f-9b02-0b22089b6540))) which basically ranks every item with its "default" value (of 5.xxx).

Related

Kentico Custom Lucene Index with multiple facets that are similar - how to query?

I have created a custom index that stores multiple extra fields that I use to filter by. Say for example I am storing some facets to select Kite colors. Some kites have one color, others have multiple.
Kite A color: dark blue red orange deep red
Kite B color: blue
Where kite A colors are dark blue, red, orange, and deep red.
A query as such
+color:blue
would return both kite a and kite b, even though kite A color is deep blue but not blue. Only kite B should be returned.
My question is this - and its probably been hard for me to find and answer because I dont know the proper terminology, but how should I be storing the values in lucene so that I can separate the values (delimiter?). In addition, how do I phrase the query so that if I search for
color:red it does not return rows that have the value color:"deep red"? And if I were to search for color:(deep red) it wont return rows that have "red" but not "deep red"
Take a look at search index analyzer types: search results depend on the analyzer type + search settings of the object (page type, custom table, etc.).
I think color field is marked tokenized in search settings, that's why it returns results that match individual tokens (subsets) of the field's value. If tokenized disabled, the search only returns items if the full value of the field exactly matches the search expression.
One suggestion here. Are you asking visitor to type in the color (I assume not), or you have a filter list that they can check to filter?
If its a filter list, then you may want to consider use "dark_blue" as the value and "dark blue" as the display. Both for content entry and filter. That way, the filter would be color:dark_blue.
Then your index for this can use "Start width" as the analyzer type, so when search "dark blue", it's looking at "dark_blue" as value, which "blue" will not return. Then, when search "blue", "dark_blue" will not show because it dosen't start with "blue..."

Getting multiple drop down dynamically in JSF

I have a hierarchy of parent child relationship in database and based on those values, I need to add new values. The hierarchy could be different and the drop down needs to be displayed dynamically. E.g. Lets say we have 2 hierarchies: NorthAmerica>USA>California and NorthAmerica>USA>GWA>Seattle. So when I try to add a new Location, if I select NA at first level, USA at second level and California at third level, then the last drop down should be of the locations which are children of California. In other case, if I select NA at first level, USA at second level, GWA at third level, then fourth drop down should show of Seattle and the last drop down should be of the locations which are children of Seattle.
The number of drop downs are shown based on the values present in the database. I doubt that it can be done using ui:repeat but I am not getting the right direction. It would be great if someone could help with any positive pointers.
If you are able to make Map<K,V> map
Where K=String(Id for value) and V= List<SomeObjectClass>
SomeObjectClass=> String id, String Value.
Now Map will looks like Key
Key Value
1 1.1,1.2
2 2.1,2.2
1.1 1.1.1,1.1.2
1.2 1.2.1,1.2.2
2.1 2.1.1,2.1.2
2.2 2.2.1,2.2.2
So if I use key 1.1 I will get list of 1.1.1, 1.1.2
One more List<ID> this will holds your selected value from drop down. And size will tell you how many drop down need to display.
Put “0” at index 0 in list, list should not be empty. Now loop over List and show number of drop down as size of list.
Dropdown value will be come from map.get(K).
UI:repeat over List<ID> var=varlistId (You know how)
Dropdown: value=#{map.get(VarID)} iteamlevel=” somevariable.level” ItemValue=”somevariable.id” var=”somevariable” DropDown END
UI:repeat END
You need to add selected Id From dropdown to list, and remove if user make any change in previous drop down, and remove all element from List.
Example:
At Page load, you list size will be 1 you have add 0 at 0 index of list, now your UI will show one drop down with map vale where you have two element 1,2;
If you select 1 or 2 from drop down, add this in list at index 1 as add method will add at last.
Now you have to drop down in UI repeat, first drop down will how 1,2 and second drop down will show 2.1,2.2,
Now if you have ten drop down and user change value in 5th drop down, now you need to loop over list and need to remove element from 6th so you list have 6 value and you UI will show only 6 drop down.
Give your suggestion below
Edited:
We can replace the map by some method which will give the next value for drop down. As suggest by #Kukeltje.

Magento 2 - How show product price in dropdown choose an option

I want to show the product difference price in the dropdown list for configurable product (choose an option) same as in magento 1.X Thanks to all!
This is a known issue in Magento 2
The JavaScript array which is used for the picklist is generated in the method getJsonConfig() in the Class
app/code/Magento/ConfigurableProduct/Block/Product/View/Type/Configurable.php
There you see two arrays added to $config: attributes and optionPrices.
attributes seems to contain the labels that are used for the dropdown.
optionPrices contains the prices which are used to refresh the price after a customer selects a different option (with a different price associated).
This will make it very difficult to show the price difference in the dropdown as the price difference values would need to be calculated in the JavaScript.
One solution that is relatively easy to implement would be something like this, but this will show the final price of each option, not the price difference:
Create a Magento 2 plugin module that is triggered after the getJsonConfig is executed: afterGetJsonConfig()
Then use the output of the getJsonConfig in afterGetJsonConfig(): $config, this array contains attributes and priceOptions array, amongst others.
First jsondecode $config
Then walk through the attributes array to determine the available options
For each option, find the matching price in priceOptions array.
Update each option label in the attributes array by concatenating the price (correctly formatted) to the existing label.
jsonencode $config
return $config

Complex data indexing with Lucene?

So I need to search a database of boxes. Each box can contain multiple items. Each box has a general description and each item has a description along with some descriptor/value pairs (ie, size:large). I want to be able to search this database using a similar set of information- I'm looking for a box like x, holding a, b, and c items. Return the box that contains the most similar items.
However, I'm confused about how I should go about indexing this data in Lucene. I know that I can index multiple values to a single field by overriding the getPositionIncrement() method of the analyzer, but how do I link descriptors to a specific item? For example, I may have 2 items in my box:
Item 1
description: pair of shoes
color: blue
Item 2
description: Jacket
color: red
and I search for
Item A
description: pair of shoes
color: red
Item B
description: Jacket
color: blue
to my knowledge, it will return the box with item 1 and 2 as a match. But I want the color to only apply to that specific item, and I need to be able to search a box to match multiple items simultaneously to find the most similar box.
The reason I'm using Lucene is because this is a regular search job that occurs on a regular basis, but it isn't live, so a search server like Solr is not needed because searches only occur in narrow windows.
In this case you need to store relation between parent document (box) and child documents (items). Fortunately there is BlockJoinQuery for such purposes. This article describes it in details for Lucene 3.x or you can use ToParentBlockJoinQuery which is available for Lucene 4.x

Setting Color for Category Lines

I have a view that displays data from several categories, where the category (bug severity in my case) is color-coded into the background color of individual entries. Now I'd like to apply the same background color to the category line itself.
As the column setting the background color for the rest of the line isn't displayed in category rows, the setting isn't applied. Is there a workaround for that?
Taken from: http://www-10.lotus.com/ldd/nd6forum.nsf/0/2765b9380021c666852572d800589f9d?OpenDocument
Here is an awkward method that works to color your category rows
differently.
Put a column before all the categorized columns. This will be your color column. Check the Use Value as Color property of the column
properties.
Use one of the functions below:
#If(#IsCategory("any")="any";any;1:1:1)
#If(#IsCategory("x")="y";z;1:1:1)
Note: in the function above, where the word "any" appears, or "x" "y"
and "z", it can be anything, matching or not. It will always evaluate
to false. If you try just #IsCategory, it will error out because that
doesn't return true. And no match you try will ever cause a true
comparison.
That said, the result is that all rows will be colored black if they
are not categories. This overrides the default text color. If you want
another color than black, then adjust the 1:1:1 accordingly
(red:green:blue up to 255 for each position, red= 255:0:0)
Now go to any column and set the text color to the row you want your
categorized rows to appear in, and click Apply to All. Voila!
I was trying to figure out how to do this programmatically and then I wondered, why not just borrow from the mail template? I'd like to suggest you check into how the ColorProfile is used there to allow users to change their color preferences based on a field value (sender name) and see if it can be done for your case.
Or, have them either access the view via a browser client or XPages in the Notes client and assign a class to that dependent on the severity.
You could build the category column formula with HTML such that when it is severe the value is "<tr class='severe'><td>CategoryNameValueHere</td></tr>" or something along those lines, right?

Resources