How to display distinct count in a hierarchical menu? - algolia

I am using instantsearch, hits and hierarchical widgets.
I have the following:
As you can see, there is a discrepancy between the count in the categories and the number of results we see.
The thing is it shows the count for the number of grouped results (ie. there is 3 variants of this camera) while showing one distinctive result since I set distinct to true.
I looked there and did not find anything useful.
How can I make the hierarchical menu display the right count?

You should be able to use the parameter facetingAfterDistinct. You can provide this parameter to the configure widget (if available) or to the searchParameters option exposed on instantsearch. Here is an example:
const search = instantsearch({
// ...
searchParameters: {
facetingAfterDistinct: true,
}
});

Related

How can I change the number of displayed suggestions with Antd Autocomplete?

By default Autocomplete seems to show 8 suggestions at a time, the rest you will have to scroll down to see it. There are no component property related to this number in Antd documentations. Is there any way to change that to another fixed number? How about making it display all?
Internally Autocomplete use the component Select and make all Select properties available, even internal props. listHeight can be used to increase the height of the suggestion dropdrown list. As note in Antd's Select documentation:
Virtual scroll internal set item height as 32px
To make Autocomplete display 10 items for example, set listHeight={320} to Autocomplete. To make it display all items, pass an arbitrary large number to listHeight like 999999 or Number.MAX_SAFE_INTEGER

Is there a way to highlight a specific item in the search results?

I have been trying to implement a slight change in the behavior of the chosen dropdown search results, but there doesn't seem to be any straightforward way to get at them. I have a list of countries preceded by three-letter ISO country code. I would like to be able to search as usual, but highlight the country if there is an exact match on the country code. The problem is that the matching country code will not always be the first item in the list. A more general request would be able to access the result list, and set the selection to some item other than the first.
By inspection, it looks to me like the search results only exist as a jquery object and within that the list items include a data-option-array-index with the original option list index, so I could find the item that I know I want highlighted in that DOM object and set the class "highlighted". But I also might need to scroll it into view, and messing with the underlying DOM directly is not ideal, so it would really be nice to have access to Chosen functions that would do that.
So, I figured it out, by accessing DOM. I have the index in the initial array that I want to highlight, and the following code will do it, assuming it is in the result list (using lodash _.find):
var highlightChosenResult = function(index) {
var resultList = $('li.active-result');
var result = _.find(resultList, function(el) {
return +$(el).attr('data-option-array-index') === index;
});
if (result) {
this.chosenApi.result_do_highlight($(result));
}
}

how to hide and unhide authoerable tabs depending upon value selected from a drop down in CQ5

i am trying to create a footer component in CQ5, where i have 4 columns & all are autherable.
But we have to make no of columns autherable too i.e based on a value selected form a dropdown we have to open those many tabs for authoring those many columns only.
i have created a dropdown and have a maximum range of 6 columns. i know that i have to configure a listener for this purpose but don't know how . Requirement is like if i select 3 from the drop down then 3 tabs should come to author 3 columns
pls help me , i am middle of something very important.i need the solution very early too as i have to finish the job as soon as possible
I might be late for this by now but in case you still need it:
You need to add a listener node before closing your drop-down element:
<listeners
jcr:primaryType="nt:unstructured"
loadcontent="function(box){ //here you also need to handle the hide/unhide when the panel loads for the first time. Use this.getValue() to retrive the intial value }"
selectionchanged="function(box, value) {
for(var c=1;c<=value;c++){
this.findParentByType('tabpanel').unhideTabStripItem("tab"+c); // You need to handle the opposite with hideTabStripItem("tab"+c);
}
}"/>
Then on both "loadcontent" and "selectionchange" (these are events on your drop-down) grab the current selected value and use it to hide/unhide the tabs. In this case the tabs would be named "tab1", "tab2", etc, make sure you get the names right.
The ExtJS in the events is finding the "tabpanel" container for the whole dialog, and then hiding/unhiding based on name. You could also set to enable/disable using the methods ".enable()" and ".setDisabled(true)". Just make sure you get the reference to the tab first if you want to do this (something like ".getComponent(tabName).enable()").
I didn't test this specific code, I couldn't find my actual example from my code base but this should take you in the right direction.

How can i achieve this smart search in obj c

In my iphone app i have a search screen with UISearchDisplaycontroller uisng this against each scopeBar key words we can filter the search result, But using only this scopeBar buttons i couldnt reach my requirement.
See, I have a list of members, I need to search members based on state, country, city, name. and i should display these search types in a bar (say scopBar).
After selecting a scopeBar button(say Country)if we type 'India' in the search bar it should display all the members of that country. How can i achieve these kind of search ? I have tried many search tutorials, But those didnt help me. Please help me out.
Thanks in Advanced!
As per Apple's Sample code, we can use 2 arrays during search, 1 actual, and 2nd is filtered array as in example reference :
http://developer.apple.com/library/ios/#samplecode/TableSearch/Listings/MainViewController_m.html#//apple_ref/doc/uid/DTS40007848-MainViewController_m-DontLinkElementID_6
But in your case, we are requiring 3 arrays, third array will be local array (let's call scopedFilteredArray) during filteration.
Search all objects by scope bar : Using Predicate (contained by scopedFilteredArray, from actual array).
Search filtered objects from scopedFilteredArray and save them in filteredArray for display.
Have a modal window appear to select your extra filter parameters (put whatever control you want there), and create a global search nsmutabledictionary to store your parameters.
I put it to appear on the book (bookmarks) button (it passed apple checks), for easy access.

Dashcode - how to register and use my own filterPredicate procedurally

In my Dashcode mobile app I have a listView that is bound to a datasource. By default it shows everything in the datasource. If I add a search field the user may limit the list to just the records that match their search text.
I want to create my own preset searches attached to buttons that would be able to load a list view and show only the records from my datasource that match my custom search.
It seems like this ought to be possible, but so far I haven't figured out how to register my own filterPredicate and then use it.
I'm guessing this is what I want to do because it seems like this is what the search field part does.
Has anyone figured out how to do this?
Any help would be appreciated
According to the dashcode starter section, you could use something along the lines of:
itemDescription = Class.create(DC.ValueTransformer, {
transformedValue: function(value){
return "Page: " + value;
}
});