# I can not see the document in the result

**URL:** https://discuss.elastic.co/t/i-can-not-see-the-document-in-the-result/143063
**Category:** Elasticsearch
**Created:** [August 5, 2018, 1:59pm UTC](https://discuss.elastic.co/t/i-can-not-see-the-document-in-the-result/143063 "2018-08-05T13:59:45Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Masoumeh\_Shavikloo](https://avatars.discourse-cdn.com/v4/letter/m/a8b319/32.png) [@Masoumeh\_Shavikloo](https://discuss.elastic.co/u/Masoumeh_Shavikloo)
#### Post date: [August 5, 2018, 1:59pm UTC](https://discuss.elastic.co/t/i-can-not-see-the-document-in-the-result/143063/1 "2018-08-05T13:59:46Z")

</div>

I am using elasticsearch-PHP and new to it. I wrote two scripts, one is for indexing a document under a custom analyzer:

```
<?php
require_once 'init.php';

if (!empty($_POST)) {
    if (isset($_POST['title'], $_POST['body'], $_POST['keywords'])) {
        $title = $_POST['title'];
        $body = $_POST['body'];
        $keywords = explode(',', $_POST['keywords']);

        $index = [
            'index' => 'myindex2',
            'body' => [
                'settings' => [
                    'analysis' => [
                        'analyzer' => [
                            'my_analyzer' => [
                                "type" => "custom",
                                'tokenizer' => 'standard',
                                'filter' => [
                                    'lowercase',
                                    'asciifolding',
                                    'snowball',
                                    "language" => "english"
                                ]
                            ]
                        ]
                    ]
                ]
            ]
        ];
        $client->indices()->create($index);

        $params = [
            'index' => 'myindex2',
            'type' => 'article',
            'id' => '1',
            'body' => [
                'title' => $title,
                'body' => $body,
                'keywords' => $keywords
            ]
        ];

        $response = $client->index($params);

        if ($response) {
            print_r($response);
        }
    }
}

?>

```

And another script is for searching inside indexed documents:

```
<?php
require_once 'init.php';

if (isset($_GET['q'])) {
    $q = $_GET['q'];

    $params = [
        'index' => 'myindex2',
        'type' => 'article',
        'size' => 10,
        'body' => [
            "query" => [
                "bool" => [
                    "should" => [
                        [
                            "match_phrase" => [
                                "body" => [
                                    'query' => $q,
                                    'analyzer' => 'my_analyzer',
                                    'slop' => 3,
                                    "boost" => 8.0
                                ]
                            ]
                        ],
                        [
                            "match" => [
                                "body" => [
                                    'query' => $q,
                                    'analyzer' => 'my_analyzer',
                                    "boost" => 3.0
                                ]
                            ],
                        ]
                    ]
                ]
            ]
        ]
    ];
    $query = $client->search($params);
    echo '<pre>', print_r($query), '</pre>';
}
?>

```

As shown in the first script, I used "snowball" token filter in my custom analyzer (my\_analyzer) and used that inside the search query in the second script. Assuming I index, for example, a document such as :

title: "test"  
body: "The 2 QUICK Brown-Foxes jumped over the lazy dog's bone."  
keywords : ""

when I search " **the**" or " **over**" or " **bone**", I see the above document in the result. but when I search " **Foxes**" or " **fox**" or " **lazy**" or " **lazi**", I do not see the above document in the result. May you please clarify me?  
Thanks a lot

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [August 5, 2018, 11:14pm UTC](https://discuss.elastic.co/t/i-can-not-see-the-document-in-the-result/143063/2 "2018-08-05T23:14:28Z")

</div>

You need to define a mapping which uses my\_analyzer at index time.

---

<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: [September 2, 2018, 11:14pm UTC](https://discuss.elastic.co/t/i-can-not-see-the-document-in-the-result/143063/3 "2018-09-02T23:14:30Z")

</div>

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