# Geospatial search between polylines\[multiple geo\_point\] and points

**URL:** <https://discuss.elastic.co/t/geospatial-search-between-polylines-multiple-geo-point-and-points/2691>\
**Category:** Elasticsearch\
**Created:** [June 15, 2015, 12:18pm UTC](https://discuss.elastic.co/t/geospatial-search-between-polylines-multiple-geo-point-and-points/2691 "2015-06-15T12:18:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ryan\_Li](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ryan_li/32/665_2.png) [@Ryan\_Li](https://discuss.elastic.co/u/Ryan_Li)\
**Post date:** [June 15, 2015, 12:18pm UTC](https://discuss.elastic.co/t/geospatial-search-between-polylines-multiple-geo-point-and-points/2691/1 "2015-06-15T12:18:37Z")

</div>

Hi  
Sorry if it is too long, I'll try to keep the content short.

My scenario is I have many polylines (which basically are array of geo\_points with directions, and I can store the index of each point) indexed as my documents for search. And I need to query out with polyline is the closest one give two geo\_points with direction(say start\_point and end\_point).  
For that, in theory what I need to do is

1. calculate score using start\_point for all points in polyline, and get the max. also the index of the geo\_points in the polyline say index\_one
2. do the same thing using end\_point and get a max\_score plus another index of the geo\_point say index\_two
3. Sum the score from step 1 and 2.
4. exclude the polylines where index\_one is bigger than index\_two(which means the polyline's direction is different from the points direction).

I've tried a few approach, but no luck so far.

1. Simple treat the polyline as array of geo\_points works great for calculating score, but I can't get the index of the scored geo\_point of that polyLine.
2. I've tried to index the points as nested documents but the problem is seems I can't query one nested document field twice (or at least can't see the hit). Also I've heard that nested document cost a lot of resource and likely will cause performance problem.

Just wondering did any one done something similar? What are the possible approaches to try with?  
And what would be the possible performance issue?

Thanks for your time in advance

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 12:07am UTC](https://discuss.elastic.co/t/geospatial-search-between-polylines-multiple-geo-point-and-points/2691/2 "2017-07-06T00:07:28Z")

</div>


