cominvent / autocomplete Goto Github PK
View Code? Open in Web Editor NEWSolr advanced autocomplete example
Solr advanced autocomplete example
#### #### Licensed to the Apache Software Foundation (ASF) #### http://www.apache.org/licenses/LICENSE-2.0 #### See http://www.cominvent.com/?p=576 for instructions #### AutoComplete example core ========================= This is an example of how to do advanced super-flexible AutoComplete using a dedicated Solr core. A blog post detailing the autocomplete technique is found at http://www.cominvent.com/?p=576 This code is intended as a template for you to get started. Normally you will copy the "ac" folder, holding the configuration of the autocomplete core, into your own multi core SolrHome, but for this simple example we assume that you run it stand-alone in the provided solr-home. We assume Linux/Mac/Cygwin, feel free to contribute start script for Windows :) Quick start =========== 1. Set environment variable JETTY_HOME to your solr/example folder (solr3.x) export JETTY_HOME=/home/john/solr-3.5.0/solr/example 2. Start Solr using solr-home ./run-solr.sh 3. In another SHELL window, feed the example data (you need curl) ./feed-ac.sh 4. Goto http://localhost:8983/solr/ac/browse and start typing. The example data is country names and names of large cities from Geonames, and they are boosted by population so if you type 'c' you'll see China on top.. Using your own data =================== Of course you want suggestions for your own data. The easiest is to start with the exampledata/ac-example.csv file, keep the first line and enter your own data below. Here is a short description of the columns and how they are configured to work in Solr's schema.xml: id : Unique id textsuggest : Main text for matching and display subtext : Extra text not being searched but displayed in () extrasearch : Extra text not being displayed but searched (full words only) extradisplay : Extra text not being searched, for additional display type : You may choose your own types, e.g. Country, City. Each type will be suggested in its own section in the result action : Optional field to give a hint to Ajax comp about what to do when suggestion is clicked, e.g. search, jump-to-url etc value : Optional field to give details about how to execute action popularity : This number gets boosted into the score for relevancy tuning thumbnail_url : Example of extra data field to be able to display an image phonetic : If filled, this suggestion will also be matched phonetically To learn more about how the autoSuggester is built and how to tune further, read the blog post at http://www.cominvent.com/?p=576 About the data set ================== We've used data from Geonames dataset, adapted for this example Licensed under Creative Commons http://creativecommons.org/licenses/by/3.0/ Country names: Deducted from http://download.geonames.org/export/dump/countryInfo.txt We use country ISO code for extra search, Capital city as sub-text, population as popularity City names: Deducted from http://download.geonames.org/export/dump/cities15000.zip, filtered to cities with population above 100.000 We use the country as sub-text and population as popularity Flags: Flags used in /browse GUI links to http://flags.blogpotato.de/ and are CC-by-sa licensed
Prefix: I'm not a Solr or Java guy - so apologies if this issue turns out to be a non-issue :)
After following the README.txt instructions, I was able to navigate to /solr/ac/browse but the jquery auto-complete plugin wasn't firing. Checking the browser's console log, I could see the problem was that requests to /solr/ac/select kept returning a 404 error.
Adding a "/select" request handler to solr-home/ac/conf/solrconfig.xml solved the problem (note: I am running solr v3.6.0).
Code for request handler is here: http://www.hastebin.com/mivocolebi.xml [ can't work out how to embed it within this comment ]
The pf parameter has no impact on boosting exact phrase matches.
This code is crated for SOLR 3.5, but at the moment the actual SOLR version is 6.3. It would be good to have the compatibility with new version of SOLR.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.