On Wed, Sep 4, 2013 at 4:56 PM, sebastian.manolescu
<sebastian.manole...@yahoo.com> wrote:
> I want to implement spell check functionality offerd by solr using MySql
> database, but I dont understand how.
> Here the basic flow of what I want to do.
>
> I have a simple inputText (in jsf) and if I type the word shwo the response
> to OutputLabel should be show.
>
> First of all I'm using the following tools and frameworks:
>
> JBoss application server 6.1.
> Eclipse
> JPA
> JSF(Primefaces)
>
> Steps I've done until now:
>
> Step 1: Download solr server from:
> http://lucene.apache.org/solr/downloads.html Extract content.
>
> Step 2: Add to Envoierment variable:
>
> Variable name: solr.solr.home Variable value :
> D:\JBOSS\solr-4.4.0\solr-4.4.0\example\solr --- where you have the solr
> server
>
> Step 3:
>
> Open solr war and to solr.war\WEB-INF\web.xml add env-entry - (the easy way)
>
> solr/home D:\JBOSS\solr-4.4.0\solr-4.4.0\example\solr java.lang.String
>
> OR import project change and bulid war.
>
> Step 4: Browser: localhost:8080/solr/
>
> And the solr console appears.
>
> Until now all works well.
>
> I have found some usefull code (my opinion) that returns:
>
>     [collection1] webapp=/solr path=/spell
> params={spellcheck=on&q=whatever&wt=javabin&qt=/spell&version=2&spellcheck.build=true}
> hits=0 status=0 QTime=16
>
> Here is the code that gives the result from above:
>
> SolrServer solr;
>     try {
>         solr = new CommonsHttpSolrServer("http://localhost:8080/solr";);
>
>     ModifiableSolrParams params = new ModifiableSolrParams();
>     params.set("qt", "/spell");
>     params.set("q", "whatever");
>     params.set("spellcheck", "on");
>     params.set("spellcheck.build", "true");
>
>     QueryResponse response = solr.query(params);
>     SpellCheckResponse spellCheckResponse =
> response.getSpellCheckResponse();
>     if (!spellCheckResponse.isCorrectlySpelled()) {
>         for (Suggestion suggestion :
> response.getSpellCheckResponse().getSuggestions()) {
>            System.out.println("original token: " + suggestion.getToken() + "
> - alternatives: " + suggestion.getAlternatives());
>         }
>     }
>     } catch (Exception e) {
>         // TODO Auto-generated catch block
>         e.printStackTrace();
>     }
>
> Questions:
>
> 1.How do I make the database connection whit my DB and search the content to
> see if there are any words that could match?

You can either write SolrJ code to index data into Solr or you can use
DataImportHandler.

http://wiki.apache.org/solr/DIHQuickStart
http://wiki.apache.org/solr/DataImportHandler

> 2.How do I make the configuration.(solr-config.xml,shema.xml...etc)?

You must first edit the schema.xml according to your data. See
https://cwiki.apache.org/confluence/display/solr/Documents%2C+Fields%2C+and+Schema+Design

> 3.How do I send a string from my view(xhtml) so that the solr server knows
> what he looks for?

For search, you can use the SolrJ java client.

https://cwiki.apache.org/confluence/display/solr/Searching
http://wiki.apache.org/solr/Solrj#Reading_Data_from_Solr

You seem to have done your homework and have found most of the
resources. We will be able to help you in a better way if you asked
specific questions instead.

-- 
Regards,
Shalin Shekhar Mangar.

Reply via email to