Search by file content

Hi,

I'm trying to implement my first Elasticsearch not get it to work and search for content of a file. I used an example found on the web .

First I created the mapping :

PUT /attachment_sample1
{
  "mappings": {
    "files": { 
      "properties": {
        "my_attachments" : { "type": "attachment" },
        "title": { "type": "string" }
      }
    }
  }
}

Then I added a file in B64 :

PUT /attachment_sample1/files/1
{
  "title": "title",
  "my_attachments" : ".... b64 ...."
}

And then I try to search for the file contents :

POST /attachment_sample1/files/_search
{
  "query": {
    "term": {
      "my_attachments": "String"
    }
  }
}

If I search for the title , siq ue is my record, but not content .

POST /attachment_sample1/files/_search
{
  "query": {
    "term": {
      "title": "String"
    }
  }
}

I have the plugins installed and that is not what I wrong .
Please , you can help me? Thank you.

use a match query instead of term

Thank you very much for the reply! I get results.

On the other hand, you can search for partial words? As for example

POST /attachment_sample1/files/_search
{
  "query": {
    "match": {
      "my_attachments": "*Part of string*"
    }
  }
}

Thank you.

Change your mapping and may be use ngrams

Ok! Thank you! Already he is working