make location fields made visible in solr - solr

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?

Related

Solr Spatial - Indexing bean

I need to index on Solr a bean that contains a generic spatial field (generally, a polygon).
I configured my Solr core schema in this way (following the tutorial here):
<fieldType name="area" class="solr.RptWithGeometrySpatialField" spatialContextFactory="org.locationtech.spatial4j.context.jts.JtsSpatialContextFactory"
autoIndex="true"
validationRule="repairBuffer0"
distErrPct="0.025"
maxDistErr="0.001"
distanceUnits="kilometers" />
....
<field name="location" type="area" indexed="true" stored="true" required="true" multiValued="false" />
My bean class is as follows:
public class MySolrBean {
#Field("id")
private String id;
#Field("location")
private Geometry location;
// getters and setters...
}
where Geometry refers to com.vividsolutions.jts.geom.Geometry (jts-1.13)
When I try to add a new bean to the index with SolrClient.addBean(Object) I get the following error:
Unable to parse shape given formats "lat,lon", "x y" or as WKT because java.text.ParseException: Unknown Shape definition [com.vividsolutions.jts.geom.Polygon:POLYGON ((1 0, 0.9980267284282716 0.0627905195293134, 0.9921147013144779 0.12533323356430...]
where WKT representation of my polygon is prefixed by the class fqn. I remember I saw a similar problem some time ago, this time when using ZonedDateTime: I changed my code to use java.util.Date and everything worked.
Though now I would not know which class to use instead of com.vividsolutions.jts.geom.Geometry and surfing the web I didn't find any documentation about that.
Anyone can help me out sorting this issue?
EDIT
Forgot to mention I'm using the latest Solr and Solrj distribution: 6.5.1

solr : how to search for a tag in a specific field

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

Is it possible to have a static index field for Liferay using solr-web plugin?

Can anyone tell me if I can associate a static index field for Liferay using the solr-web.plugin? Is there a way to define a static index in solr?
I need something similar to the following configuration in Nutch
<property>
<name>index.static</name>
<value>source:nutch</value>
</property>
This will add the field "source" as an index and its value as "nutch" to all documents in Nutch. Anything similar to this for Liferay + Solr?
Not sure for Liferay configuration, however you can add a default value in the schema.xml which will be applied to documents.
<field name="source" type="string" indexed="true" stored="true" default="Nutch" />

Using an external file to boost results. Changes in the external file not reflected

I am using drupal 7 with apachesolr module.
I have an external file field to boost the results i want. The name of the file is external_eff_ranking. In the schema, I have:
<fieldType name="pfloat" class="solr.FloatField" omitNorms="true"/>
<fieldType name="file" keyField="id" defVal="1" stored="false" indexed="false" class="solr.ExternalFileField" valType="pfloat"/>
<dynamicField name="eff_*" type="file"/>
The format of the external file is:
id1=3.1
id2=4.2
id3=5
This works as expected, the results are boosted according to the values in the file. The problem is that when the values are changed, the results do not reflect the changes. I understand that I need to commit the changes somehow, but I can not figure out how.
I tried things like:
curl http://localhost:8983/solr/update?commit=true -H "Content-Type: text/xml" --data-binary '<commit />'
but did not work.
SOLVED
The following line in my solrconfig.xml solved the problem:
<requestHandler name="/reloadCache" class="org.apache.solr.search.function.FileFloatSource$ReloadCacheRequestHandler" />
Then I hit this url (http://localhost:port/reloadCache) after each file update
Looks like this is due to a bug in solr that affects cached results. May be trying the reloadCache helps?

SOLR refuses to bring exact matches, How?

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

Resources