You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Clare Lee <ma...@gmail.com> on 2017/07/10 10:20:59 UTC
Multiple Field Search on Solr
Hello,
My name is Clare Lee and I'm working on Apache Solr-6.6.0, Solritas right
now and I'm not able to do something I want to do. Could you help me with
this?
I want to be able to search solr with multiple fields. With the basic
configurations(I'm using the core techproducts and just changing the data),
I can search like this [image: enter image description here]
<https://i.stack.imgur.com/T3XV9.png>
but I want to search like this[image: enter image description here]
<https://i.stack.imgur.com/cJ4mh.png>
I want to know which file I have to look into and how I should change the
code to do so.
I can put the space to put the additional information by copying and
pasting this in the query_form.vm file.
<input type="text" id="q" name="q" value="$!esc.html($params.get('q'))"/>
<input type="submit" id="querySubmit"/>
<input type="reset"/>
but this doesn't AND the values that I put in.
I was told that I should look where the action file is(code below), but I
cannot reach that location.
<div class="query-box"> <form id="query-form" action="#{url_for_home}"
method="GET">
<div class="inputs">
<span #annTitle("Add the query using the &q= parameter")>
Name:
<input type="text" id="q" name="q" value="$!esc.html($params.get('q'))"/>
The below code is relevant, but I don't know how to change it. (from
head.vm)
<script>
$(document).ready(function(){
$("\#q").autocomplete('#{url_for_solr}/terms', { ## backslash
escaped #q as that is a macro defined in VM_global_library.vm
extraParams:{
'terms.prefix': function() { return $("\#q").val();},
'terms.sort': 'count',
'terms.fl': 'name',
'wt': 'velocity',
'v.template': 'suggest'
}
}
).keydown(function(e){
if (e.keyCode === 13){
$("#query-form").trigger('submit');
}
});
// http://localhost:8983/solr/collection1/terms?terms.fl=name&terms.prefix=i&terms.sort=count&wt=velocity&v.template=suggest
});
Please pardon the fact that I am not familiar with html or Javascript and
also the not-good questioning. Also I can give any more information that is
needed.
Thanks,
Clare
Re: Multiple Field Search on Solr
Posted by Erik Hatcher <er...@gmail.com>.
I recommend first understanding the Solr API, and the parameters you need to add the capabilities with just the /select API. Once you are familiar with that, you can then learn what’s needed and apply that to the HTML and JavaScript. While the /browse UI is fairly straightforward, there’s a fair bit of HTML, JavaScript, and Solr know-how needed to do what you’re asking.
A first step would be to try using `fq` instead of appending to `q` for things you want to “AND" to the query that aren’t relevancy related.
Erik
> On Jul 10, 2017, at 6:20 AM, Clare Lee <ma...@gmail.com> wrote:
>
> Hello,
>
> My name is Clare Lee and I'm working on Apache Solr-6.6.0, Solritas right
> now and I'm not able to do something I want to do. Could you help me with
> this?
>
> I want to be able to search solr with multiple fields. With the basic
> configurations(I'm using the core techproducts and just changing the data),
> I can search like this [image: enter image description here]
> <https://i.stack.imgur.com/T3XV9.png>
>
> but I want to search like this[image: enter image description here]
> <https://i.stack.imgur.com/cJ4mh.png>
>
> I want to know which file I have to look into and how I should change the
> code to do so.
>
> I can put the space to put the additional information by copying and
> pasting this in the query_form.vm file.
>
> <input type="text" id="q" name="q" value="$!esc.html($params.get('q'))"/>
> <input type="submit" id="querySubmit"/>
> <input type="reset"/>
>
> but this doesn't AND the values that I put in.
>
> I was told that I should look where the action file is(code below), but I
> cannot reach that location.
>
> <div class="query-box"> <form id="query-form" action="#{url_for_home}"
> method="GET">
>
> <div class="inputs">
> <span #annTitle("Add the query using the &q= parameter")>
> Name:
> <input type="text" id="q" name="q" value="$!esc.html($params.get('q'))"/>
>
>
> The below code is relevant, but I don't know how to change it. (from
> head.vm)
>
> <script>
> $(document).ready(function(){
> $("\#q").autocomplete('#{url_for_solr}/terms', { ## backslash
> escaped #q as that is a macro defined in VM_global_library.vm
> extraParams:{
> 'terms.prefix': function() { return $("\#q").val();},
> 'terms.sort': 'count',
> 'terms.fl': 'name',
> 'wt': 'velocity',
> 'v.template': 'suggest'
> }
> }
> ).keydown(function(e){
> if (e.keyCode === 13){
> $("#query-form").trigger('submit');
> }
> });
>
> // http://localhost:8983/solr/collection1/terms?terms.fl=name&terms.prefix=i&terms.sort=count&wt=velocity&v.template=suggest
> });
>
> Please pardon the fact that I am not familiar with html or Javascript and
> also the not-good questioning. Also I can give any more information that is
> needed.
>
>
> Thanks,
>
> Clare