# The slash char in the document that may lead to unexpected result

**URL:** <https://discuss.elastic.co/t/the-slash-char-in-the-document-that-may-lead-to-unexpected-result/59484>\
**Category:** Elasticsearch\
**Created:** [September 1, 2016, 3:32am UTC](https://discuss.elastic.co/t/the-slash-char-in-the-document-that-may-lead-to-unexpected-result/59484 "2016-09-01T03:32:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![leftstar\_200](https://avatars.discourse-cdn.com/v4/letter/l/58956e/32.png) [@leftstar\_200](https://discuss.elastic.co/u/leftstar_200)\
**Post date:** [September 1, 2016, 3:32am UTC](https://discuss.elastic.co/t/the-slash-char-in-the-document-that-may-lead-to-unexpected-result/59484/1 "2016-09-01T03:32:43Z")

</div>

Elasticsearch version:  
Newest

Plugins installed: []  
None

JVM version:

OS version:  
Redhat Linux

Description of the problem including expected versus actual behavior:  
I want to got the sum for each type of downloads field. That totally likes "select sum(num) from Table group by downloads" in mysql db.

For now, My document in Index likes the following:  
{  
"\_index": "sino-564dbf686a67a515-87ae118af4eb61b8-day",  
"\_type": "downloads",  
"\_id": "AVbKDizkMS2EvdplxWkF",  
"\_score": 4.1279697,  
"\_source": {  
"downloads": "/data/attachment/file/20130820/Sinogrid1.pdf",  
"date": 20160826,  
"num": 1  
}  
},  
{  
"\_index": "sino-564dbf686a67a515-87ae118af4eb61b8-day",  
"\_type": "downloads",  
"\_id": "AVbKkkYaMS2EvdplxpFh",  
"\_score": 4.1279697,  
"\_source": {  
"downloads": "/data/attachment/file/20130820/Sinogrid2.pdf",  
"date": 20160826,  
"num": 1  
}  
},  
{  
"\_index": "sino-564dbf686a67a515-87ae118af4eb61b8-day",  
"\_type": "downloads",  
"\_id": "AVbKkhA3MS2EvdplxpFg",  
"\_score": 3.8407266,  
"\_source": {  
"downloads": "/data/attachment/file/20130820/Sinogrid2.pdf",  
"date": 20160826,  
"num": 3  
}  
},

Then, I'd like to search the sum count for each type of downloads filed. my expected return should be like this:  
/data/attachment/file/20130820/Sinogrid1.pdf 1  
/data/attachment/file/20130820/Sinogrid2.pdf 4

My search:  
GET /day/downloads/\_search  
{  
"aggs": {  
"res": {  
"terms": {  
"field": "downloads"  
},  
"aggs": {  
"sum": {  
"sum": {  
"field": "num"  
}  
}  
}  
}  
}  
}

But the return data is :  
"aggregations": {  
"res": {  
"doc\_count\_error\_upper\_bound": 0,  
"sum\_other\_doc\_count": 64,  
"buckets": [  
{  
"key": "attachment",  
"doc\_count": 75,  
"sum": {  
"value": 109  
}  
},  
{  
"key": "data",  
"doc\_count": 75,  
"sum": {  
"value": 109  
}  
},  
{  
"key": "file",  
"doc\_count": 75,  
"sum": {  
"value": 109  
}  
},  
{  
"key": "pdf",  
"doc\_count": 72,  
"sum": {  
"value": 106  
}  
},  
{  
"key": "20130820",  
"doc\_count": 46,  
"sum": {  
"value": 58  
}  
},  
{  
"key": "sinogrid2",  
"doc\_count": 12,  
"sum": {  
"value": 35  
}  
},  
{  
"key": "20131212",  
"doc\_count": 11,  
"sum": {  
"value": 34  
}  
},  
{  
"key": "sinogrid10",  
"doc\_count": 9,  
"sum": {  
"value": 18  
}  
},  
{  
"key": "20131119",  
"doc\_count": 5,  
"sum": {  
"value": 5  
}  
},  
{  
"key": "sinogrid1",  
"doc\_count": 5,  
"sum": {  
"value": 5  
}  
}  
]  
}

You can see that my downloads fields was separated by default.  
is it a issue? or any help on it?

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [September 1, 2016, 3:38am UTC](https://discuss.elastic.co/t/the-slash-char-in-the-document-that-may-lead-to-unexpected-result/59484/2 "2016-09-01T03:38:55Z")

</div>

This is because the `downloads` field is analyzed (i.e. split into tokens suitable for searches). URLs should typically _not_ be analyzed which is a setting that can be made in the mappings of an index. Please read about mappings and analysis of strings in the documentation.

---

<div class="post-metadata">

**Author:** ![leftstar\_200](https://avatars.discourse-cdn.com/v4/letter/l/58956e/32.png) [@leftstar\_200](https://discuss.elastic.co/u/leftstar_200)\
**Post date:** [September 1, 2016, 3:41am UTC](https://discuss.elastic.co/t/the-slash-char-in-the-document-that-may-lead-to-unexpected-result/59484/3 "2016-09-01T03:41:24Z")

</div>

Thanks for your quickly response.  
I will refer to documentation as soon as possible and do next action to resolve this issue to try.

BIG thanks

---

<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 5, 2017, 10:23pm UTC](https://discuss.elastic.co/t/the-slash-char-in-the-document-that-may-lead-to-unexpected-result/59484/4 "2017-07-05T22:23:25Z")

</div>


