Imagine you have a service where your users can search for different companies. Your users can enter a simple keyword(s) and then return all the companies matching that keyword(s). But a day comes when you give your users the ability to choose their location, and you would like to show how far they are from each company returned in the results. This recipe will show you how to do it.
Before reading further I advise you to read the Using field aliases recipe in the current chapter and the Storing geographical points in the index recipe from Chapter 3, Analyzing Your Text Data.
For the purpose of the recipe, let's assume that we have the following index structure (put the following field's definition into your
schema.xml
file in thefields
section):<field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false" /> <field name="name" type="text" indexed="true" stored="true"/>...