[SOLVED] Problem to create and test index manually

Hi all,

I try to make some tests but unsuccessful.

I try to create an test index:

curl -XPUT localhost:9200/test -d@index_template_test.txt

index-template-test.txt file:

{
      "settings" : {
              "analysis": {
                  "tokenizer": {
                      "custom-pattern-tokenizer": {
                          "type": "pattern",
                          "pattern": "."
                      }
                  },
                  "analyzer": {
                      "custom-analyzer": {
                          "type": "custom",
                          "tokenizer": "custom-pattern-tokenizer"
                      }
                  }
              }
 
      },
      "mappings": {
          "my_type": {
              "properties": {
                  "source_host": {
                      "type": "string",
                      "index": "analyzed",
                      "analyzer": "custom-analyzer"
                  }
              }
          }
      }
  }

After, I put data:

curl -XPUT localhost:9200/test/my_type/1 -d'
{
"source_host" : "mytest-test-1.fr"
}'

When I made a global search, I get an answer:

curl -XGET localhost:9200/test/_search?pretty
{
  "took" : 3,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "failed" : 0
  },
  "hits" : {
    "total" : 1,
    "max_score" : 1.0,
    "hits" : [ {
      "_index" : "test",
      "_type" : "my_type",
      "_id" : "1",
      "_score" : 1.0,
      "_source" : {
        "source_host" : "mytest-test-1.fr"
      }
    } ]
  }
}

But when I make a specific search, it returns nothing:

curl -XGET localhost:9200/test/my_type/_search?pretty=true -d'
{
    "query": { 
        "match": {
             "source_host" : "mytest-test-1.fr"
        }
    }
}'
{
  "took" : 1,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "failed" : 0
  },
  "hits" : {
    "total" : 0,
    "max_score" : null,
    "hits" : [ ]
  }
}

So I can't make some test with _analyze right now. Do you have any idea why I can't return a result with this kind of search ?

Result when I try an _analyze:

curl -XGET 'localhost:9200/test/_analyze?pretty&analyzer=custom-analyzer' -d mytest-test-1.fr
{
  "tokens" : [ ]
}

Thanks in advance,
Alex

After some tests, I don't understand really...

I created an index, and I put data:

curl -XPUT localhost:9200/test/my_type/1 -d'
{
 "source_host": "mytest-test-1.fr"
}'
{"_index":"test","_type":"my_type","_id":"1","_version":1,"_shards":{"total":2,"successful":2,"failed":0},"created":true}

When I retry to make a specific search like below, I get nothing:

curl -XGET localhost:9200/test/my_type/_search?pretty -d'
{
"query": {
"term": { "source_host": "mytest-test-1.fr"}
}
}'
{
  "took" : 1,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "failed" : 0
  },
  "hits" : {
    "total" : 0,
    "max_score" : null,
    "hits" : [ ]
  }
}

But with this request, I get result:

curl -XGET localhost:9200/test/my_type/_search?pretty&q=source_host:mytest-test-1.fr
 {
  "took" : 4,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "failed" : 0
  },
  "hits" : {
    "total" : 1,
    "max_score" : 1.0,
    "hits" : [ {
      "_index" : "test",
      "_type" : "my_type",
      "_id" : "1",
      "_score" : 1.0,
      "_source" : {
        "source_host" : "mytest-test-1.fr"
      }
    } ]
  }
}

Somebody can explain me why ? I become crazy about that !

Thanks in advance,
Alex

I found the problem. It was an indexing problem. My custom analyzer doesn't work so my indexation too.

Have a good day.