1

I have four pieces of data that I want to make searchable.

Town, City, Postcode, Country

What is the best way that I can make these results searchable by any of the following ways:

  • London, England
  • Swindon, Wiltshire, England
  • Wiltshire, England
  • England
  • Wiltshire
  • Swindon

I could normalise the data, but then I would get duplicate results if someone searched for simply "London".

If I had only "London, England" stored, but not just "London", then if someone searched for "London" it wouldnt find any results.

Its a catch22. How should one store addresses to allow flexibility when the user is searching?

Matt
  • 22,721
  • 17
  • 71
  • 112
J.Zil
  • 2,397
  • 7
  • 44
  • 78
  • 1
    If you have "London, England" indexed, searches for "London" would match that. Could you add some samples of data you have, not just queries? – Fuxi Aug 01 '12 at 10:49

3 Answers3

0

The best approach would be to use solr spatial search features http://wiki.apache.org/solr/SpatialSearch/ but that would require access to a mapping data service which could return the latitude / longitude of the location and store that with the solr record. Then do the same lookup on searching to get the latitude / longitude and you will be able to do radius searches and get much more accurate results compared to text searching on locations.

d whelan
  • 804
  • 5
  • 8
0

is best to follow the suggestion of the previous answer. you should add a field location and configure schema.xml

added to the section <fieldType>

 <fieldType name="location" class="solr.LatLonType" subFieldSuffix="_coordinate"/>

added to the section <field>

<field name="location" type="location" indexed="true" stored="true" required="true" />

 <dynamicField name="*_coordinate"  type="tdouble" indexed="true"  stored="false"/> 

Now update your index solr/dataimport?command=delta-import

can make your query &q=:&fq={!geofilt pt=45.15,-93.85 sfield=store d=5}

http://wiki.apache.org/solr/SpatialSearch http://wiki.apache.org/solr/SpatialSearchDev

Edy Aguirre
  • 2,113
  • 20
  • 20
0

If you don't have the geospatial data available you could give Herarchical Faceting a try. It indexes the data in a specific manner, allowing queries within a hierarchy, e.g.:

Document: England > London > Chelsea

Index: 0/England, 1/England/London, 2 England/London/Chelsea

Query: facet.field = category, facet.prefix = 1/London, facet.mincount = 1

There is some redundancy in the index, but it should be negligable in most cases.

kpentchev
  • 3,040
  • 2
  • 24
  • 41