I am using Solr’s JSON output for AJAX example as a basis for my project. However I have modified things by adding a drop-down menu in the form and added faceting to the params.
Params:
function getstandardargs() {
var params = [
'wt=json'
,'facet=true'
,'facet.field=brand1'
,'facet.field=brand2'
,'facet.field=brand3'
,'facet.field=brand4'
,'facet.limit=2'
];
Drop- down menu:
<form name="f1" onsubmit='xmlhttpPost("/solr/select"); return false;'>
<p>query: <input name="query" type="text">
<select id="Entity">
<option value="brand1">Universal</option>
<option value="brand2">Paramount</option>
<option value="brand3">Fox</option>
<option value="brand4">Sony</option>
</select>
<input value="Go" type="submit"></p>
I am trying to add the drop-down value to my facet query result as such:
var rsp = eval("("+str+")");
var c=document.getElementById("Entity");
cat=c.options[c.selectedIndex].value;
var output=rsp.facet_counts.facet_fields;
html += "Entity: " + output+'.'+cat;
My facet response sends back: Entity: [object Object].Universal. How do I add the drop-down value to the response query correctly so Solr can actually return the proper facet values? Many thanks.
you will undoubtedly reduce the complexity of this problem by using a library for your ajax request because:
select options
evalAnd since you said your response is “Entity: [object Object].Universal”, can you try to use
console.log( output );to tell us what is returned in the object, officially? there’s a possibility that by concatenating strings with an object, you’re messing up the output objectif it is in fact an object, you can access it iteratively like this: