I want to add such a search bar in my site that users search my site and they can get instant result though live search like wikipedia. How can be done this job?
What you want is an ajax request which queries a php file and search for the keyword in your db and return the topic to be displayed as search predictions. Here is a good example that you can try it out.
https://www.w3schools.com/php/php_ajax_livesearch.asp
In a nutshell, you need an endpoint that you can call each time you change the input with the current results. That endpoint would then spit back out search results which you could render to show the user.
Related
When I use algolia's instantsearch, the url that I hit returns all the attributes for the object that is hit. I have multiple different types of users and I don't want to just display something like a user's email to the entire world. Is there a way to query algolia differently so that I can limit the returned resultset before it comes to the page?
My current idea is to funnel everything through the our backend but I don't like the idea of limiting the spead of my search results by my own server response speed.
Here's an example of the algolia hit that returns all of my keys:
https://identifier-dsn.algolia.net/1/indexes/localhost_users/query?x-algolia-agent=Algolia%20for%20vanilla%20JavaScript%203.18.0&x-algolia-application-id=identifier&x-algolia-api-key=secret_letters
For better control over what kind of data is returned, you can configure the attributesToRetrieve and attributesToHighlight of your index. Take a look at the documentation for the attributesToRetrieve here.
Edit: Also, use unretrievableAttributes if you want don't want someone with a Search API key to get access to some attributes
I'm trying to retrieve the web page content of Bing Images for a specific query.
I'm currently communicating with Bing through the following URL (in case of a sample foo search), from curl command line tool:
curl http://www.bing.com/images/search?q=foo
Since the safe search filter is enabled by default, I'd need to disable it.
How can I do that?
I know that direct API access would be preferable, but I need to bypass them and retrieve the entire web page.
I saw that from the web page, the safe search is disabled through Ajax calls.
What URL should I contact to make a search with safe search disabled?
The correct solution is to use the query parameter safeSearch=off, like
curl http://www.bing.com/images/search?q=foo&safeSearch=off
This is not documented anywhere I could find.
Add &adlt_set=off to the Bing Search url to close SafeSearch.
&adlt_set=moderate to filter adult images and videos but not text from your search results.
&adlt_set=Strict to filter out adult text, images, and videos from your search results.
The solution is simply to add &safesearch=off to the search URL.
so what I'm hoping to do is having a box that's similar to the tweet box. When the user enters '#' (I know, use keyup to detect when), and then he types a letter (i.e. 'J'), I want to get 4 of the people he's following and show it as a suggestion (i.e. James, Jay, Jack, etc...). The way I would approach this is make an AJAX call which will query the sql table to find all of the users whom the user follows and whose names begin with that substring, but what I've noticed that FB does with friends is that it loads all of the user's friends upon visit, meaning that if you were to type '#' then it would scour a client-side array rather than constantly query the database. Although I'm not so sure if that's better... Is it better? Also, when would I load all of the user's following users? As soon as he/she visits any page? And is it conventional?
tl;dr - Should users that a logged-in user be pre-loaded and stored as an array or constantly obtained by querying the database?
Thanks.
When an ajax call has been sent to server a thread is generated in Server's CPU. So if you have 10 user on line search for a friend list it will consume more CPU.
So better option is that fetch list in group. e.g. you want to search Arjun,
If you type A, it will fetch list of all friend with name A. so when you type R(second letter) it will not send ajax request again.
Is there any way to take the list of available positions for a company from JobVite using javascript (I would prefer if it returned JSON)?
I would like to take 5 random open position and display them in a recruiting region on the website I am working on.
I can confirm that Jobvite DOES have an API, and it returns results in JSON! You need to submit a request to obtain an API key. (Look in the Category dropdown menu)
http://recruiting.jobvite.com/support/customer
Yes. You'll need an API key and secret as blastronaut points out. Then hit this URL:
https://api.jobvite.com/v1/jobFeed?api=KEY&sc=SECRET&companyId=COMPANYID
The API documentation is here: Jobvite Services API PDF
Well, if they have no API, I guess you're going to need to use cURL or something similar and then your PHP could return JSON encoded results?
Failing that, you might check out:
https://github.com/dylang/jobvite
I am working on a big site, and in the site there is a search module. Searching is done by using a a lot of user submitted values, so in pagination I must pass all these data to the next page, appending the values to url make the url very big.
Sso how can I solve this issue? I am planning to use a javascript based page submission (POST) with all the values in hidden fields to the next page the read all the values from the next page.
Will it cause any problems? Or should I use database to keep the search criterias?
I would create a server side object, possibly with a database backend which is updated by the different pages.
It is at my opinion the most clear and easy solution. Giving parameters from page to page, either by post or javascript or cookie will work too but it's more of a quirk in my experience.
Also if a search query is so complex that it needs multiple pages to create it, it might be helpfull for the user to have all the data stored on the server so he can change it more easily by switching back and forth between the different pages.
I would store all the search criterias in some kind of session-store on the server when the initial search is being triggered.
For pagination I would retrieve the criterias from the session-store and then just show the appropriate results. Also I would append some kind of key to the pagination links (so this would be the only hidden post-field) under which the search criterieas can be found.
Even though the session is per user, you might have several search windows open within the same session, and you don't want to mess them up with the pagination.
In order to make a reliable search with pagination, we need to do a bit more than normal.
We need to handle the following cases.
Once search is done, user may choose to do browser back and forward. Here, if you are doing form submission on every page, it would be an overload. Also, if user presses browser refresh button, it will unnecessarily warn him that data is being submitted.
Searching on a large database with lots of criteria is costly. Hence, optimization is important.
So you should NOT do the following:
Submit data on every page change
Not store data in cookie. (This is not secure and not even reliable.)
For large database with complex query, cache the result in session.
In case, you need very up-to-date and real-time result, ignore point (3) and try doing partial search for every page.
Thus, for your case, you can do the following:
When user searches first time, make the form POST data to a search page.
This search page will store the search query in session and generate a unique id for it.
Now render the result page. The result page will be passed the search id (generated in point 2) and the page number. Example result.aspx?searchId=5372947645&page=2
The result page will puck up the query from session using the searchId and then provide result based on the page number sent.
Using hidden fields and POST method should be fine too unless you are able to get them on the next page right.
To supplement Sarfraz's answer...
It's not necessary to use Javascript to make a POST.
<form action="destination_url" method="POST">
...
</form>