I have the following field type (notice no filters, no tokenizers)
<fieldType name="text_names" class="solr.StrField" />
I create a field in my schema using that type:
<field name="exact_type" type="text_names" indexed="true" stored="true" />
now, I search q=*:*&fq=exact_type:aa&fl=exact_type
I still get results which have other than 'aa' in the exact_type field.
What am I missing here?
Also this behaves the same:
q=exact_type:aa&fl=exact_type
I don't think that "q=*:*" works with DisMaxHandler and I believe that you are using it ,the correct syntax for both the queries should be:
q=&fq=exact_type:aa&fl=exact_type
fq=exact_type:aa&fl=exact_type
Related
I am very new to solr. I am trying to add a large number of fields to the schema. I am using version 8.1, and it is my understanding that it should be done through the API.
I am trying to upload all fields using curl, but keep getting errors. It works fine through the web interface.
1. Where can I find the correct field types? I checked
here, but I get error messages like "Field type 'StrField' not found".The values are also different from the ones that I get presented with in the webinterface.
2. Enum valuesI found documentation, which also results in an unknown field error. For enumns I don't see an option in the web interface.
<\p>
curl -X POST -H 'Content-type:application/json' --data-binary '{"add-field":{"name":"TEST","type":"string","required":"true","stored":true,"indexed":"true"}}' http://localhost:8983/api/cores/tgec/schema
{
"responseHeader":{
"status":400,
"QTime":27},
"error":{
"metadata":[
"error-class","org.apache.solr.api.ApiBag$ExceptionWithErrObject",
"root-error-class","org.apache.solr.api.ApiBag$ExceptionWithErrObject"],
"details":[{
"add-field":{
"name":"TEST",
"type":"StrField",
"required":"true",
"stored":true,
"indexed":"true"},
"errorMessages":["Field 'TEST': Field type 'StrField' not found.\n"]}],
"msg":"error processing commands",
"code":400}}
There is field type named "string" and the class is of "solr.StrField".
Its defined in schema.xml as below.
<fieldType name="string" class="solr.StrField" sortMissingLast="true" docValues="true" />
Then when you define a field, you mention a type string to it as below.
<field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false" />
You need to change the "type":"StrField" to "type":"string".
I am using exclude and tag for faceting. Strange this is it works where I don't have space in value.
http://192.168.2.114:8983/solr/customer/select?indent=on&q=*:*&fq=(%7B!tag%3DstateName%7DstateName:%22Gujarat%22)&fq=(%7B!tag%3DstateName%7DstateName:%22AndhraPradesh%22)&facet=true&facet.limit=100&facet.mincount=0&facet.field=%7B!ex%3DstateName%7DcountryName&facet.field=%7B!ex%3DstateName%7DstateName&facet.field=%7B!ex%3DstateName%7Dicity&facet=true - This works
but
http://192.168.2.114:8983/solr/customer/select?indent=on&q=*:*&fq=(%7B!tag%3DstateName%7DstateName:%22Gujarat%22)&fq=(%7B!tag%3DstateName%7DstateName:%22Andhra Pradesh%22)&facet=true&facet.limit=100&facet.mincount=0&facet.field=%7B!ex%3DstateName%7DcountryName&facet.field=%7B!ex%3DstateName%7DstateName&facet.field=%7B!ex%3DstateName%7Dicity&facet=true - This does not
The only difference between these two is a space in {!tag=stateName}stateName="Andhra Pradesh" ({!tag=stateName}stateName="AndhraPradesh" - this works).
I don't understand why. I have tried encoding the URL, i.e. put + or %20 for space, still no luck.
PFA images for the same
Working copy
EDIT
Here is the definition of stateName field.
<field name="stateName" type="string" multiValued="false" indexed="true" stored="true"/>
<fieldType name="string" class="solr.StrField" sortMissingLast="true"/>
Problem is that local parameters in query must be at the beginning of the string:
{!tag=stateName}(stateName:"Andhra Pradesh")
and not
({!tag=stateName}stateName:"Andhra Pradesh")
You can also avoid parenthesis:
{!tag=stateName}stateName:"Andhra Pradesh"
i am testing solr query for geographical search, this is my query:
SolrQuery query =new SolrQuery();
query.setParam("q","*:*");
query.setParam("fq","geofilt");
query.setParam("d","100000");
query.setParam("pt","51.53750834,-0.19329616");
query.setParam("sfield","location_s");
i am getting no results although there is very near points and also exact point to the pt.
any idea whats the reason??
hint: im using this field type for spatial search (the one comes in the schema.xml by default):
<fieldType name="location_rpt" class="solr.SpatialRecursivePrefixTreeFieldType"
geo="true" distErrPct="0.025" maxDistErr="0.000009" units="degrees" />
because when i try to use this one as mentioned in the solr website i get an error:
<fieldType name="location_rpt" class="solr.SpatialRecursivePrefixTreeFieldType" spatialContextFactory="com.spatial4j.core.context.jts.JtsSpatialContextFactory"
autoIndex="true"
distErrPct="0.025"
maxDistErr="0.000009"
units="degrees" />
and this is my field definition:
<field name="location_s" type="location_rpt" indexed="true" stored="true"/>
thanks in advance!
instead of this kind of field names please add only 1 field that served for both x/y :
<dynamicField name="*_coordinate" type="tdouble" indexed="true" stored="true"/>
That will allow you to put directly datas in solr geo format :
"env": "DEV",
"latlgn_0_coordinate": -2.6263,
"latlgn_1_coordinate": -44.1978,
please take a look to both solr spatialsearch & solr wiki spatialsearch
As said above, please make sure to have in your runtime classpath.
You might download and install in your path the JTS library : JTS Library
Solr Manual solr install documentation
The JTS jar file must be on Solr's classpath as well. Due to a
combination of things, JTS can't simply be referenced by a ""
entry in solrconfig.xml; it needs to be in WEB-INF/lib in Solr's war
file, basically.
enjoy :)
Thanks jean, it worked with me without using JTS library, solr schema comes already with this field type that I used:
<fieldType name="location_rpt" class="solr.SpatialRecursivePrefixTreeFieldType"
geo="true" distErrPct="0.025" maxDistErr="0.000009" units="degrees" />
I defined a field of that type and it worked. This is my query:
SolrQuery query =new SolrQuery();
query.set("q","*:*");
query.set("fq","{!geofilt}");
query.set("pt","32.014708,35.873725");
query.set("sfield","location");
query.set("d","100");
Thanks.
I want to perform a search for occurrence of specific tags in a field:
<field name="productTagValues" type="text_en" indexed="true" stored="true" multiValued="true" />
A document can have multiple tags. Eg.:
"productTagValues": [
"Everyday Wear",
"Double Chain",
"Traditional and Imitation",
"Gold Plating",
"Metal Alloy",
"Special Occasions or Gifts"
}
I want to retrieve all the docs that have a specific tag. Eg. all the docs with Gold Plating as one of the tags.
I tried using fq=productTagValues:Gold Plating. But it also returned docs that didn't have Gold Plating in the productTagValues field.
Could someone please help me with this
As I said in the comment, the solution was to do a query:
q=productTagValues:Gold Plating
instead of
fq=productTagValues:Gold Plating
I have the following field defined in solr (schema.xml)
<field name="store" type="location" indexed="true" stored="true"/>
If I search for say this-
&fq={!geofilt pt=45.15,-93.85 sfield=store d=5}
Then I can see the location coordinates in the search result.
But the field "store" seems to be a hidden field under normal circumstances. How do I get the coordinates to be a part of the search result for normal searches? (q=*:* for example)
I just verified that this works correctly for both Solr 3.1 and Solr 4.0-dev with the example data.
Example:
http://localhost:8983/solr/select?q=:&fl=id,store&wt=json&indent=true
[...]
"response":{"numFound":17,"start":0,"docs":[
{
"id":"SP2514N",
"store":"35.0752,-97.032"},
{
"id":"6H500F0",
"store":"45.17614,-93.87341"},
{
"id":"F8V7067-APL-KIT",
"store":"45.18014,-93.87741"},
[...]
Did you perhaps change this setting and forget to re-index or forget to commit?