# Search by complete text on array property

**URL:** <https://discuss.elastic.co/t/search-by-complete-text-on-array-property/91259>\
**Category:** Elasticsearch\
**Created:** [June 29, 2017, 9:40am UTC](https://discuss.elastic.co/t/search-by-complete-text-on-array-property/91259 "2017-06-29T09:40:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![srinivasulu](https://avatars.discourse-cdn.com/v4/letter/s/b4bc9f/32.png) [@srinivasulu](https://discuss.elastic.co/u/srinivasulu)\
**Post date:** [June 29, 2017, 9:40am UTC](https://discuss.elastic.co/t/search-by-complete-text-on-array-property/91259/1 "2017-06-29T09:40:05Z")

</div>

Hi,

I have following records:

curl -XPUT "[http://localhost:9200/movies/movie/1](http://localhost:9200/movies/movie/1)" -d'  
{  
"title": "The Godfather",  
"director": "Francis Ford Coppola",  
"year": 1972,  
"genres": ["Crime", "Drama"]  
}'

curl -XPUT "[http://localhost:9200/movies/movie/2](http://localhost:9200/movies/movie/2)" -d'  
{  
"title": "Lawrence of Arabia",  
"director": "David Lean",  
"year": 1962,  
"genres": ["Adventure", "Biography", "Drama"]  
}'

curl -XPUT "[http://localhost:9200/movies/movie/3](http://localhost:9200/movies/movie/3)" -d'  
{  
"title": "To Kill a Mockingbird",  
"director": "Robert Mulligan",  
"year": 1962,  
"genres": ["Crime", "Drama", "Mystery"]  
}'

curl -XPUT "[http://localhost:9200/movies/movie/4](http://localhost:9200/movies/movie/4)" -d'  
{  
"title": "To Kill a Mockingbird11",  
"director": "Robert Mulligan",  
"year": 1962,  
"genres": ["Crime", "Drama values", "Mystery"]  
}'

curl -XPUT "[http://localhost:9200/movies/movie/5](http://localhost:9200/movies/movie/5)" -d'  
{  
"title": "Apocalypse Now",  
"director": "Francis Ford Coppola",  
"year": 1979,  
"genres": ["Drama values test", "War"]  
}'

curl -XPUT "[http://localhost:9200/movies/movie/6](http://localhost:9200/movies/movie/6)" -d'  
{  
"title": "Kill Bill: Vol. 1",  
"director": "Quentin Tarantino",  
"year": 2003,  
"genres": ["Action", "Crime", "Thriller", "Drama", "Drama values", "Drama values test"]  
}'

curl -XPUT "[http://localhost:9200/movies/movie/7](http://localhost:9200/movies/movie/7)" -d'  
{  
"title": "The Assassination of Jesse James by the Coward Robert Ford",  
"director": "Andrew Dominik",  
"year": 2007,  
"genres": ["Biography", "Crime", "Drama", "Drama values"]  
}'

## If I search by "drama values", below are the expected results:

{  
"title": "To Kill a Mockingbird11",  
"director": "Robert Mulligan",  
"year": 1962,  
"genres": ["Crime", "Drama values", "Mystery"]  
}

{  
"title": "Kill Bill: Vol. 1",  
"director": "Quentin Tarantino",  
"year": 2003,  
"genres": ["Action", "Crime", "Thriller", "Drama", "Drama values", "Drama values test"]  
}

{  
"title": "The Assassination of Jesse James by the Coward Robert Ford",  
"director": "Andrew Dominik",  
"year": 2007,  
"genres": ["Biography", "Crime", "Drama", "Drama values"]  
}

## If I search by "drama values test", below are the expected results:

{  
"title": "Kill Bill: Vol. 1",  
"director": "Quentin Tarantino",  
"year": 2003,  
"genres": ["Action", "Crime", "Thriller", "Drama", "Drama values", "Drama values test"]  
}

{  
"title": "Apocalypse Now",  
"director": "Francis Ford Coppola",  
"year": 1979,  
"genres": ["Drama values test", "War"]  
}

## If I search by "drama", it will display all results except following results:

{  
"title": "To Kill a Mockingbird11",  
"director": "Robert Mulligan",  
"year": 1962,  
"genres": ["Crime", "Drama values", "Mystery"]  
}'

{  
"title": "Apocalypse Now",  
"director": "Francis Ford Coppola",  
"year": 1979,  
"genres": ["Drama values test", "War"]  
}

I am new to elasticsearch. I tried many ways, but I did not get expected results.

Can you help me to achive this ?

---

<div class="post-metadata">

**Author:** ![polyfractal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/polyfractal/32/48162_2.png) [@polyfractal](https://discuss.elastic.co/u/polyfractal)\
**Post date:** [July 7, 2017, 1:38pm UTC](https://discuss.elastic.co/t/search-by-complete-text-on-array-property/91259/2 "2017-07-07T13:38:28Z")

</div>

What does your query look like, and what part isn't working as expected?

---

<div class="post-metadata">

**Author:** ![SKumarMN](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/skumarmn/32/27537_2.png) [@SKumarMN](https://discuss.elastic.co/u/SKumarMN)\
**Post date:** [July 7, 2017, 3:42pm UTC](https://discuss.elastic.co/t/search-by-complete-text-on-array-property/91259/3 "2017-07-07T15:42:37Z")

</div>

Search is dependent on the analyzer set . If you need exact match, you would need to store them as not\_analyzed fields. Below is the example which might help you

My Mappings:

```
{
    "movies": {
        "mappings": {
            "movie": {
                "properties": {
                    "director": {
                        "type": "text",
                        "fields": {
                            "keyword": {
                                "type": "keyword",
                                "ignore_above": 256
                            }
                        }
                    },
                    "genres": {
                        "type": "text",
                        "fields": {
                            "keyword": {
                                "type": "keyword",
                                "ignore_above": 256
                            }
                        }
                    },
                    "title": {
                        "type": "text",
                        "fields": {
                            "keyword": {
                                "type": "keyword",
                                "ignore_above": 256
                            }
                        }
                    },
                    "year": {
                        "type": "long"
                    }
                }
            }
        }
    }
}

**Sample Query**

```

{  
"query" : {"match" :{ "genres.keyword" : "Drama values" } }  
}

{  
"query" : {"match" :{ "genres.keyword" : "Drama values test" } }  
}

---

<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:** [August 4, 2017, 3:43pm UTC](https://discuss.elastic.co/t/search-by-complete-text-on-array-property/91259/4 "2017-08-04T15:43:08Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
