0
votes

I have solr documents that look like this:

<doc>
    <str name="some_attribute">some_attribute_value</str>
    <!-- ... -->
    <arr name="locationCoordinates">
      <str>48.117,11.539</str>
      <str>23.423,11.342</str>
      <!-- ... -->
    </arr>
</doc>

My question is whether it's possible to filter the returned fields of a document to only return certain values, for example to only return the locationCoordinates that are within a 50 km range of another point and leave the others out.

I.e. return the above document, but with only the first locationCoordinates.

I don't really know whether this should even be possible in Solr (because of the document-oriented structure), but I can at least ask :).

Maybe I should also elaborate on the way I want to use this feature and alternatives I "found" for this:

  1. change the document design to create one document per location (Pro: works, Cons: need to check for duplicates on the client side, heaps of duplicated data in the Solr-database)

  2. leave it with this structure (Pro: works, don't have to change the current structure, Cons: I have to sort the correct coordinates out by myself (on the client) and therefore encounter problems with distance calculation (I already filter the documents by distance beforehand, and maybe I will lose some data if I compute the distance on the client-side badly)

  3. create a new Document "type" for the locations (and their names, etc.) on the Solr-side and use a foreign-key-like structure to add the locations to the articles and in order to compute distances I have to query for reachable locations first and then join on the articles (Pro: everything works on the solr-side, Cons: I will need Solr-Joins for that)

1
Answer probably found on this question: stackoverflow.com/questions/14015696/… But how can I achieve the behaviour mentioned above? - Martin Braun

1 Answers

0
votes
  1. change the document design to create one document per location (Pro: works, Cons: need to check for duplicates on the client side, heaps of duplicated data in the Solr-database)

If this is your only concern, probably you can consider making the locationCoordinates as your unique_key for each document.

By doing this, you are not allowing duplicate locationCoordinates in your Index, thereby eliminating the need to check for duplicates on the client side.