Note that there are some explanatory texts on larger screens.

plurals
  1. POMapping ElasticSearch GeoPoint Fields
    primarykey
    data
    text
    <p>We store documents that look something like this:</p> <pre><code>{ "id": "dQesbpxeQniUWXpsnjPQ", "title": "Golf in Hamburg, Altona", "user": "CtGjEaDxSrhPbf7W7NcH", "location": { "id": "Q6sZhRHdiS3mP2innbJ9", "name": "Hamburg, Altona", "lat": 53.55, "lon": 9.93333, "slug": "hamburg-altona" }, "_type": "announcement" } </code></pre> <p>We need the <code>announcement.location.slug</code> to be <code>not_analyzed</code> (it's a slug, after all)</p> <p>However the mapping won't take, we have these settings:</p> <pre><code>Tire.index(@@index_name) do delete create(mappings: { announcement: { properties: { "id" =&gt; { type: 'string', index: 'not_analyzed' }, "user" =&gt; { type: 'string', index: 'not_analyzed' }, "location" =&gt; { type: 'geo_point', properties: { "slug" =&gt; { type: 'string', index: 'not_analyzed' } } }, "times" =&gt; { type: 'string', analyzer: 'keyword' }, "sport" =&gt; { "properties" =&gt; { "slug" =&gt; { type: 'string', index: 'not_analyzed' } } } } } }, settings: { index: { number_of_shards: 1, number_of_replicas: 0 } }) refresh end </code></pre> <p><strong>Note:</strong> The same mapping in <code>curl</code> syntax also doesn't work, but is less readable for SO, so I'm posting the Ruby code.</p> <p>It seems like <code>geo_point</code> is overriding all other mappings on that part of the document. <a href="http://www.elasticsearch.org/guide/reference/mapping/geo-point-type.html" rel="nofollow">The documentation</a> seems to agree.</p> <p>I'm sure there's a way to use the <code>lat_lon</code> option, but I can't find any documentation on how that might work. (I assume one maps the individual <code>lat</code> and <code>lon</code> fields with <code>lat_lon</code> settings)</p> <p>It might also be possible, I had hoped to use <a href="http://www.elasticsearch.org/guide/reference/mapping/multi-field-type.html" rel="nofollow">the <code>multi</code> field type</a> but that doesn't seem to apply to whole sub-trees of the main document attributes.</p> <p>How can I proceed without having to change my whole data model?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload