Hi Rocha,
In your webapp I guess you have at list a view and a service layers.
The indexing and search modules should preferably be hosted at the service
layer.
I recommend you read the Api doc (
http://lucene.apache.org/solr/4_2_1/solr-solrj/index.html) to get a sense
of what you can do with SolrJ.
Followinf is a Basic Example Facets with SolrJ:
//adding the query keyword to the SolrQuery object
 mySolrQuery.setQuery(queryBuilder.toString());
// add a facet field
mySolrQuery.addFacetField("myFieldName")
//add a facet query
validatedFromTheLast7DaysFacetQuery = validationDateField + ":[NOW/DAY-7DAY
TO NOW]"
mySolrQuery.addFacetQuery(validatedFromTheLast7DaysFacetQuery)

//send the request in HTTP POST as with HTTP GET you run into issues when
the request string is too long.
QueryResponse queryResponse =  getSolrHttpServer().query(mysolrQuery,
METHOD.POST);

//write a transformer to convert the Solr response to a format
understandable by the caller (the client of the search service)
//List of results to transform
SolrDocumentList responseSolrDocumentList = queryResponse.getResults();
//get the facet fields, interate over the list, parse each FacetField and
extract the information you are intersted in
queryResponse.getFacetFields()
//get the facet query from the response
 Map<String, Integer> mapOfFacetQueries = queryResponse.getFacetQuery();
The keys of this map are your facet queries. The values are the counts you
display to the user. In general, I have an identifier for each facetQuery.
When I parse the keys of this map of facet queries, I return the identifier
of each facet along with its count (if the count > 0 of course). The caller
is aware of this identifier so it knows what to display to the user.

When the user clicks on a facet, you send it as a search criteria along
with the initial keywords to the search service. The criteria resulting
from the facet is treated as a filter query. That is how faceting search
works. Adding a filter to your query is as simple as this snippet
mySolrQuery.addFilterQuery(myfilterQuery). should you are filtering because
your user click on the previously defined facet query, then the filter
query is the same as the facet query. that is myfilterQuery =
validationDateField + ":[NOW/DAY-7DAY TO NOW]".

I hope this helps.

Cheers,

Maj


On 24 April 2013 17:27, richa <striketheg...@gmail.com> wrote:

> Hi Maj,
>
> Thanks for your suggestion.
> Tell me one thing, do you have any example on solrj? suppose I decide to
> use solrj in simple web application, to display faceted search on web page.
> Where will this fit into? what will be the flow?
>
> Please suggest.
>
> Thanks
>
>
> On Wed, Apr 24, 2013 at 11:01 AM, Majirus FANSI [via Lucene] <
> ml-node+s472066n4058610...@n3.nabble.com> wrote:
>
> > Hi richa,
> > You can use solrJ (
> > http://wiki.apache.org/solr/Solrj#Reading_Data_from_Solr)
> > to query your solr index.
> > On the wiki page indicated, you will see example of faceted search using
> > solrJ.
> > 2009 article by Yonik available on
> > searchhub<http://searchhub.org/2009/09/02/faceted-search-with-solr/>
> > is
> > a good tutorial on faceted search.
> > Whether you go for MVC framework or not is up to you. It is recommend
> > tough
> > to develop search engine application in a Service Oriented Architecture.
> > Regards,
> >
> > Maj
> >
> >
> > On 24 April 2013 16:43, richa <[hidden email]<
> http://user/SendEmail.jtp?type=node&node=4058610&i=0>>
> > wrote:
> >
> > > Hi,
> > > I am working on a POC, where I have to display faceted search result on
> > web
> > > page. can anybody please help me to suggest what all set up I need to
> > > configure to display. I would prefer java technologies. Just to
> mention,
> > I
> > > have solr cloud running on remote server.
> > > I would like to know:
> > > 1. Should I use MVC framework?
> > > 2. How will my local interact with remote solr server?
> > > 3. How will I send query through java code and what technology I should
> > use
> > > to display faceted search result?
> > >
> > > Please help me on this.
> > >
> > > Thanks,
> > >
> > >
> > >
> > > --
> > > View this message in context:
> > >
> http://lucene.472066.n3.nabble.com/Solr-faceted-search-UI-tp4058598.html
> > > Sent from the Solr - User mailing list archive at Nabble.com.
> > >
> >
> >
> > ------------------------------
> >  If you reply to this email, your message will be added to the discussion
> > below:
> >
> >
> http://lucene.472066.n3.nabble.com/Solr-faceted-search-UI-tp4058598p4058610.html
> >  To unsubscribe from Solr faceted search UI, click here<
> http://lucene.472066.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4058598&code=c3RyaWtldGhlZ29hbEBnbWFpbC5jb218NDA1ODU5OHwxNzIzOTAyMzYx
> >
> > .
> > NAML<
> http://lucene.472066.n3.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
> >
> >
>
>
>
>
> --
> View this message in context:
> http://lucene.472066.n3.nabble.com/Solr-faceted-search-UI-tp4058598p4058619.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>

Reply via email to