Attachment Search

Hi

Im following this link to implement my first attachment script

After indexing if I run

http://localhost:9400/mytestatachment/person/1

I get

{"_index":"mytestatachment","_type":"person","_id":"1","_version":1,"found":true,"_source":{
"cv": "e1xydGYxXGFuc2kNCkxvcmVtIGlwc3VtIGRvbG9yIHNpdCBhbWV0DQpccGFyIH0="
}}

but with search Query

{
"query": {
"query_string": {
"query": "ipsum"
}}}

I'm not getting any result. Any configuration is missing with Base64?

What is the mapping?

Here is the mapping

{
"properties": {
"cv": { "type": "attachment" }
}}

Which versions are you using?

Elastisearch

{
"status" : 200,
"name" : "The Symbiote",
"cluster_name" : "elasticsearch",
"version" : {
"number" : "1.4.4",
"build_hash" : "c88f77ffc81301dfa9dfd81ca2232f09588bd512",
"build_timestamp" : "2015-02-19T13:05:36Z",
"build_snapshot" : false,
"lucene_version" : "4.10.3"
},
"tagline" : "You Know, for Search"
}

elasticsearch-mapper-attachments version --> 3.1.1

Well. Look at the README. You should use version 2.4.3.
Related doc here: https://github.com/elastic/elasticsearch-mapper-attachments/tree/v2.4.3#version-243-for-elasticsearch-14

1 Like

Yes it works !! But the result is in base64, any option to show the actual text or should I have to read the file and show?

{
  "took": 9,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "failed": 0
  },
  "hits": {
    "total": 2,
    "max_score": 0.095891505,
    "hits": [
      {
        "_index": "mytestatachment",
        "_type": "person",
        "_id": "4",
        "_score": 0.095891505,
        "_source": {
          "cv": "e1xydGYxXGFuc2kNCkxvcmVtIGlwc3VtIGRvbG9yIHNpdCBhbWV0DQpccGFyIH0="
        }
      },
      {
        "_index": "mytestatachment",
        "_type": "person",
        "_id": "2",
        "_score": 0.095891505,
        "_source": {
          "cv": "e1xydGYxXGFuc2kNCkxvcmVtIGlwc3VtIGRvbG9yIHNpdCBhbWV0DQpccGFyIH0="
        }
      }
    ]
  }
}

You have to change the mapping and store the inner cv field. See what is done there: https://github.com/elastic/elasticsearch-mapper-attachments/tree/v2.4.3#highlighting-attachments

Then ask for it using fields like here: https://github.com/elastic/elasticsearch-mapper-attachments/tree/v2.4.3#querying-or-accessing-metadata

1 Like

Yes this works for me !! Thank you.