Returning the number of results? - algolia

I'm looking to return the number of results found in an ajax fashion on Algolia instant search.
A little field saying something like "There are X number of results" and refines as the characters are typed.
I've read you utilise 'nbHits' but i'm unsure of how to go about it.. Being from a design background.
Thanks for help in advance.

The instantsearch.js stats widget shows the number of results and speed of the search. If you don't want to use the widget, I believe you can still use {{nbHits}} inside of your template wherever you want the number to print.

Very easy when you know how, Thanks for pointing me in the right direction Josh.
This works:
search.addWidget(
instantsearch.widgets.stats({
container: '.no-of-results'
})
);

Related

Is there way to customize col_max value without change python-click source code?

I'm facing a very concrete problem with python-click 8.1.3. The helptext created by Click wastes too much column space when an option name is a tad long. Depicted in picture below:
I trace into Click's source code, and pinpoint a hardcoded value in HelpFormatter.write_dl(), the col_max parameter determines first-column max-width, which is 30, and I hope to reduce it to 16.
As a Click-library user, how can I achieve this without modifying Click's source code? Maybe some class inheritance or patching trick?
Thank you in advance.
You can do something like this:
class MyHelpFormatter(click.HelpFormatter):
def write_dl(self, rows, col_max=5, col_spacing=2):
super().write_dl(rows, col_max, col_spacing)
click.Context.formatter_class = MyHelpFormatter
Check this answer for a similar example

Query by Attribute Value - VersionOne REST

Given a Number Attribute with a specific value, I want to find the story with that value.
For example, I have a request with the number R-56614.
What I'm attempting is along the line of this:
rest-1.v1/Data/Story?sel=SuperAndUp&where=Attribute.Number="R-57154"
Any suggestions would be greatly appreciated.
I figured it out.
rest-1.v1/Data/Request?where=Request.Number="R-57154"

Not able to select desired value form dropdown while running webdriver script

On running webdriver code control finds the dropdown clicks on it but selection of a value does not occur. I tried with "select by index" and "select by value" methods but no use. I think it sof type bootstrap dropdown.most posts direct to usage of aforesaid functions but im unable to use it . any help will be greatly appreciated.
50
100
200
300
400
500
We really need more information, including what programming language you are using, what code you are executing, and the HTML you are executing against. Looking at your comment in your original question, and without knowing any of the aforementioned, all I can suggest is selecting the times with XPATH. In Python it would be something like:
driver.find_element_by_xpath("//select[#ng-model='recordnumber']/option[#value='300']").click() # this would select the "300" item
Thanks for your effort but i found the solution . just we need to click on the dropdown and call sendKeys("value to be entered into the dropdown").
Eg: drp=findElement(By.xpath("dropdown element locator").click();
drp.sendKeys("value to shown in dropdown");

Accessing nested elements in python

I am new to python.I am posting here for the first time and I know question might be quite basic but problem is I can't figure out myself.
Lets say I have
List=[("a,"b"),("c","d"),("e","f")]
I want the user to enter one of the elements of one of the tuples as input and the other element is printed.Or more precisely I would say that just one of elements in List[x][0] is input and corresponding List[x][1] element is printed as output.I hope it makes sense.
Thanks!
Please check List in the question.I think you forgot a quote(") in the first tuple.[("a^here,"b"),("c","d"),("e","f")]
I think this might help you.
List=[("a","b"),("c","d"),("e","f")]
c=raw_input('ENTER A CHARACTER-')
for i in xrange(len(List)):
if c in List[i]:
ind=List[i].index(c)
print List[i][abs(ind-1)]
break

ElasticSearch - filter terms for autocomplete

I would like for an autocomplete to get the terms starting with some specific characters.However, the terms returned do not begin with the specified text ("wer" in this case), and more than that, no matter what the prefix content is, they are always the same. The query I am using now is:
{"facets":
{"count":
{"terms":
{"field":"content"},
"facet_filter":
{"prefix":{"content":"wer"}}
}
},
"size":0
}
I am wondering what am I missing or doing wrong. Any help much appreciated. Thanks!
Perhaps you miss a "query" entry after the facet_filter.
If this does not help try regex pattern for facets, but be aware that facets will be removed in future updates of elasticsearch.
http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-facets-terms-facet.html#_regex_patterns