lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Hatcher <erik.hatc...@lucidworks.com>
Subject Re: Need help in velocity search UI
Date Tue, 02 Jun 2015 17:09:56 GMT
Jeetendra -

Forget about url_for_facet_filter and any other macros (since these were built for the techproducts
/browse UI, not necessarily general purpose and not for use with multi-select facets)… just
concern yourself with the actual Solr URL that you need to submit.  In the example you provided
you probably want to use OR instead of AND - unless you’re trying to find documents that
have actually have all of those values, not just all documents that all documents that have
_any_ of those values.  Once you’ve got the URLs to Solr right and getting the data you
want, then you can macro things as desired.

You’re asking about some fiddly niche stuff with those macros that are just getting in your
way.  Again, don’t worry about the macros and just concern yourself with the Solr actions
until you get that where you want.  But yes, in general /browse will work with any arbitrary
fq passed to it - it’s just a Solr request that displays the results through templates rather
than as JSON, XML, or some other format.

—
Erik Hatcher, Senior Solutions Architect
http://www.lucidworks.com <http://www.lucidworks.com/>




> On Jun 2, 2015, at 12:58 PM, Jeetendra Gangele <gangele397@gmail.com> wrote:
> 
> Thanks Erik  for reply.
> I am building some kind of semantic search for one of the google Hackathon
> project so I need this UI for Demo only.
> 
> I already have java script which is allowing user to select multiple facets
> and I am getting all the facets selecting by user in array in java script.
> Now I want to pass this to solr? by using url_for_facet_filter ? below is
> my UI and java script which allow use to select multiple things and capture
> in java scripts array, now the question is how can I make rest call using
> these captured data to slor.
> One way I can thing of is like create the URI like below and when user hot
> on submit call the below URI(highlights things I will pass as variable from
> user selected facets)
> 
> 
> http://54.242.13.110:8080/solr/collection1/browse?&fq=idx_type:companies&q=&fq=(*:*
> AND topics:"*revenue*" AND topics:"*reports/results*" AND NOT topics:"
> *aerospace*”)
> Will this work? or I need to create the search page on which this data will
> be shown or on the existing page data will be filtered and rendered?
> 
> 
> 
> http://54.146.195.106:8080/solr/collection1/browse
> 
> 
> Also below is my facet_fields.vm source code. please help me how can I
> selected things to url_for_facet_filter
> 
> #**
> *  Display facets based on field values
> *  e.g.: fields specified by &facet.field=
> *#
> 
> #if($response.facetFields)
>  <h2 #annTitle("Facets generated by adding &facet.field= to the request")>
>    Filters
>  </h2>
>  #foreach($field in $response.facetFields)
>    ## Hide facets without value
>    #if($field.values.size() > 0)
>      <span class="facet-field">$field.name</span>
>      <ul>
>        #foreach($facet in $field.values)
>          <li>
>                <span class="showhide">#if($facet.name!=$null)$
> facet.name#else <http://facet.name/#else>
> <em>missing</em>#end($facet.count)</span>
>            <div class="showhidecontainer">
>                <select name="$facet.name" class="filter $field.name">
>                      <option value="-1" selected>select</option>
>                        <option value="1">Yes</option>
>                      <option value="0">No</option>
>              </select>
>            </div>
>          </li>
>        #end
>      </ul>
>    #end  ## end if > 0
>  #end    ## end for each facet field
> #end      ## end if response has facet fields
> <input type="button" value="filter" id="filterme"/>
> 
> <script>
> function filter() {
> var topicsYes = [], topicsNo = [], semsYes = [], semsNo = [];
> $(".filter").each(function() {
>        //decide if its topic or sem
>  var filter = $(this);
>  var value = filter.val();
>  if(filter.is(".topics")) {
>        if(value === "1") topicsYes.push(filter.attr("name"));
>    if(value === "0") topicsNo.push(filter.attr("name"));
>  }
>  else if(filter.is(".semTags")) {
>    if(value === "1") semsYes.push(filter.attr("name"));
>    if(value === "0") semsNo.push(filter.attr("name"));
>  }
>  else {
>        console.log("something wrong");
>  }
> });
> console.log(topicsYes, topicsNo, semsYes, semsNo);
> }
> $(function() {
>        $("#filterme").click(filter);
> $(".showhide").click(function() {
>         $(this).next().slideToggle();
> });
> });
> 
> 
> 
> On 2 June 2015 at 21:56, Erik Hatcher <erik.hatcher@lucidworks.com> wrote:
> 
>> Jeetendra -
>> 
>> First steps - implement what you want with static HTML/JavaScript so that
>> you have the interface in place.  It can get hairy with the
>> Velocity/HTML/JavaScript/Solr stuff all intermingled*.   By doing things
>> statically (without Velocity, and even without Solr) you’ll get the UI
>> pieces implemented and then can make it dynamic.   The
>> #url_for_facet_filter is designed for single select faceting.  For
>> multi-select faceting (within the Velocity UI) you’ll need JavaScript that
>> can allow a user to select multiple facets before submitting (or maybe
>> submit each one and allow refining).  There is no built-in example with
>> multi-select faceting to go by.  You’ll need to get savvy with the tag/ex
>> faceting “local” parameters - see
>> https://cwiki.apache.org/confluence/display/solr/Faceting#Faceting-LocalParametersforFaceting
>> <
>> https://cwiki.apache.org/confluence/display/solr/Faceting#Faceting-LocalParametersforFaceting>
>> for more details.
>> 
>> As has been said on this thread, the /browse UI may not be the right way
>> for you to build this - if your purpose is a proof of concept or demo
>> that’s fine.  If it is a production system for other users to access you
>> must be aware that /browse (or any wt=velocity) UI is *directly* Solr and
>> any user that can hit that could also affect the actual Solr server and
>> indexed data, unless you employed some kind of proxy or firewall to prevent
>> unauthorized access.
>> 
>>        Erik
>> 
>> —
>> Erik Hatcher, Senior Solutions Architect
>> http://www.lucidworks.com <http://www.lucidworks.com/>
>> 
>> * It got cleaned up a lot in 5x/trunk of Solr, see
>> http://svn.apache.org/repos/asf/lucene/dev/trunk/solr/contrib/velocity/src/resources/velocity/facets.vm
>> <
>> http://svn.apache.org/repos/asf/lucene/dev/trunk/solr/contrib/velocity/src/resources/velocity/facets.vm>
>> and
>> http://svn.apache.org/repos/asf/lucene/dev/trunk/solr/contrib/velocity/src/resources/_macros.vm
>> <
>> http://svn.apache.org/repos/asf/lucene/dev/trunk/solr/contrib/velocity/src/resources/_macros.vm
>>> 
>> 
>> 
>> 
>>> On Jun 2, 2015, at 7:58 AM, Jeetendra Gangele <gangele397@gmail.com>
>> wrote:
>>> 
>>> Hey Michal thanks for your reply.
>>> 
>>> Actually I am beginner I am listing below steps to perform.
>>> 1. add entry in query.vm  add hidden field with name 'fq'
>>> 2. now through js append in this field
>>> 
>>> My problem is ,facet_fields.vm is another file how can I get 'fq' access
>>> this in another file?
>>> 
>>> Can you help me in writing sequence of  steps to make it work?
>>> 
>>> 
>>> On 2 June 2015 at 17:01, Michał B. . <m.bienkowski@gmail.com> wrote:
>>> 
>>>> It's 'Boost by Price' field in default velocity template. You can find
>> it
>>>> in query.vm.
>>>> 
>>>> R.
>>>> Michał
>>>> 
>>>> 2015-06-02 13:28 GMT+02:00 Jeetendra Gangele <gangele397@gmail.com>:
>>>> 
>>>>> what is bf field and where can I find?
>>>>> 
>>>>> On 2 June 2015 at 15:42, Michał B. . <m.bienkowski@gmail.com>
wrote:
>>>>> 
>>>>>> HI,
>>>>>> 
>>>>>> Look how bf field is done. You could simply add hidden field with
name
>>>>> 'fq'
>>>>>> and in JS append values to it.
>>>>>> 
>>>>>> Regards,
>>>>>> Michal
>>>>>> 
>>>>>> 2015-06-02 11:17 GMT+02:00 Jeetendra Gangele <gangele397@gmail.com>:
>>>>>> 
>>>>>>> Hi Michael
>>>>>>> 
>>>>>>> Thanks for your reply. I got this is an macro.
>>>>>>> 
>>>>>>> I am trying to modify the facet_fields.vm. how it works is like
for
>>>>> each
>>>>>> $
>>>>>>> field.name, $facet.name it gives the result.
>>>>>>> 
>>>>>>> But now what I want is I want user to select multiple facets
from
>>>>> fields
>>>>>>> and once user hit the filter button which I provided below I
need to
>>>>> send
>>>>>>> all the select fields with selected facets? how can I do this
.
>>>>>>> since url_for_facet_filter is executed server side how can I
pass all
>>>>> the
>>>>>>> selected facets of the fields, you can have a look at the UI
below
>>>>>>> 
>>>>>>> http://54.146.195.106:8080/solr/collection1/browse
>>>>>>> 
>>>>>>> 
>>>>>>> Also below is my facet_fields.vm source code. please help me
how can
>>>> I
>>>>>>> selected things to url_for_facet_filter
>>>>>>> 
>>>>>>> #**
>>>>>>> *  Display facets based on field values
>>>>>>> *  e.g.: fields specified by &facet.field=
>>>>>>> *#
>>>>>>> 
>>>>>>> #if($response.facetFields)
>>>>>>> <h2 #annTitle("Facets generated by adding &facet.field=
to the
>>>>>> request")>
>>>>>>>   Filters
>>>>>>> </h2>
>>>>>>> #foreach($field in $response.facetFields)
>>>>>>>   ## Hide facets without value
>>>>>>>   #if($field.values.size() > 0)
>>>>>>>     <span class="facet-field">$field.name</span>
>>>>>>>     <ul>
>>>>>>>       #foreach($facet in $field.values)
>>>>>>>         <li>
>>>>>>>               <span class="showhide">#if($facet.name!=$null)$
>>>>>>> facet.name#else<em>missing</em>#end($facet.count)</span>
>>>>>>>           <div class="showhidecontainer">
>>>>>>>               <select name="$facet.name" class="filter $field.name
>>>> ">
>>>>>>>                     <option value="-1" selected>select</option>
>>>>>>>                       <option value="1">Yes</option>
>>>>>>>                     <option value="0">No</option>
>>>>>>>             </select>
>>>>>>>           </div>
>>>>>>>         </li>
>>>>>>>       #end
>>>>>>>     </ul>
>>>>>>>   #end  ## end if > 0
>>>>>>> #end    ## end for each facet field
>>>>>>> #end      ## end if response has facet fields
>>>>>>> <input type="button" value="filter" id="filterme"/>
>>>>>>> 
>>>>>>> <script>
>>>>>>> function filter() {
>>>>>>> var topicsYes = [], topicsNo = [], semsYes = [], semsNo = [];
>>>>>>> $(".filter").each(function() {
>>>>>>>       //decide if its topic or sem
>>>>>>> var filter = $(this);
>>>>>>> var value = filter.val();
>>>>>>> if(filter.is(".topics")) {
>>>>>>>       if(value === "1") topicsYes.push(filter.attr("name"));
>>>>>>>   if(value === "0") topicsNo.push(filter.attr("name"));
>>>>>>> }
>>>>>>> else if(filter.is(".semTags")) {
>>>>>>>   if(value === "1") semsYes.push(filter.attr("name"));
>>>>>>>   if(value === "0") semsNo.push(filter.attr("name"));
>>>>>>> }
>>>>>>> else {
>>>>>>>       console.log("something wrong");
>>>>>>> }
>>>>>>> });
>>>>>>> console.log(topicsYes, topicsNo, semsYes, semsNo);
>>>>>>> }
>>>>>>> $(function() {
>>>>>>>       $("#filterme").click(filter);
>>>>>>> $(".showhide").click(function() {
>>>>>>>        $(this).next().slideToggle();
>>>>>>> });
>>>>>>> });
>>>>>>> </script>
>>>>>>> -
>>>>>>> 
>>>>>>> 
>>>>>>> On 2 June 2015 at 14:29, Michał B. . <m.bienkowski@gmail.com>
wrote:
>>>>>>> 
>>>>>>>> Look at the VM_global_library.vm file.
>>>>>>>> 
>>>>>>>> Regards,
>>>>>>>> Michal
>>>>>>>> 
>>>>>>>> 2015-06-02 10:47 GMT+02:00 Jeetendra Gangele <gangele397@gmail.com
>>>>> :
>>>>>>>> 
>>>>>>>>> Hi All I was trying to modify the "facet_fields.vm" do
anybody
>>>> know
>>>>>>> where
>>>>>>>>> is the location of the function "url_for_facet_filter
"?
>>>>>>>>> 
>>>>>>>>> Also where will be log stored ?
>>>>>>>>> 
>>>>>>>> 
>>>>>>>> 
>>>>>>>> 
>>>>>>>> --
>>>>>>>> Michał Bieńkowski
>>>>>>>> 
>>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> --
>>>>>> Michał Bieńkowski
>>>>>> 
>>>>> 
>>>> 
>>>> 
>>>> 
>>>> --
>>>> Michał Bieńkowski
>>>> 
>>> 
>>> 
>>> 
>>> --
>>> Hi,
>>> 
>>> Find my attached resume. I have total around 7 years of work experience.
>>> I worked for Amazon and Expedia in my previous assignments and currently
>> I
>>> am working with start- up technology company called Insideview in
>> hyderabad.
>>> 
>>> Regards
>>> Jeetendra
>> 
>> 


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message