Skip to content

Instantly share code, notes, and snippets.

@JnBrymn
Created July 31, 2012 02:08
Show Gist options
  • Save JnBrymn/3212774 to your computer and use it in GitHub Desktop.
Save JnBrymn/3212774 to your computer and use it in GitHub Desktop.
Creating Suggest As You Type for Solr
#!/usr/bin/env bash
#this is how to create suggest as you type for finding a name (searching over last and first names)
#the search is only issued upon 3 characters or more because too many results will come back otherwise. This is a search for "tho" which could be Thomas (a first name) or Thompson (a last name).
curl "http://localhost:8983/solr/select?indent=on&qf=first_name%20last_name&defType=edismax&facet=truel&facet.field=first_name&facet.field=last_name&facet.mincount=1&fl=first_name%20last_name&q=tho*&facet.prefix=tho"
#as soon as a space is issued notice the change in the facet.prefix
curl "http://localhost:8983/solr/select?indent=on&qf=first_name%20last_name&defType=edismax&facet=truel&facet.field=first_name&facet.field=last_name&facet.mincount=1&fl=first_name%20last_name&q=thomas+&facet.prefix="
#starting the second name
curl "http://localhost:8983/solr/select?indent=on&qf=first_name%20last_name&defType=edismax&facet=truel&facet.field=first_name&facet.field=last_name&facet.mincount=1&fl=first_name%20last_name&q=thomas+r*&facet.prefix=r"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment