I am indexing it the same way as you suggested.

I am able to properly index into elasticsearch. But the search
functionality only not working. With the same code in other machine i am
able to index and able to search also.




On Tue, Apr 1, 2014 at 4:29 PM, Binh Ly <binhly...@yahoo.com> wrote:

> Attachments require a specific mapping. It is likely that your mapping is
> not correct. Here is a simple example of how to index a PDF with the proper
> attachment type:
>
>         class T1
>         {
>         }
>
>         private static void IndexPdf()
>         {
>             var settings = new ConnectionSettings(new Uri("
> http://localhost:9200";), "_all");
>             var client = new ElasticClient(settings);
>
>             client.CreateIndex("foo", c => c
>                 .AddMapping<T1>(m => m
>                     .Properties(props => props
>                         .Attachment(s => s
>                             .Name("file")
>                             .FileField(fs => fs.Store())
>                         )
>                     )
>                 )
>             );
>
>             var doc = new { file = new {
>                 content =
> Convert.ToBase64String(File.ReadAllBytes(@"C:\ESData\pdf\fn6742.pdf")),
>                 _indexed_chars = -1
>             }};
>
>             client.Index(doc, i => i.Index("foo").Type("t1"));
>         }
>
> Then after that you can run a search like this:
>
> POST localhost:9200/foo/t1/_search
> {
>   "fields": "file",
>   "query": {
>     "match": {
>       "file": "blah bah"
>     }
>   }
> }
>
>  --
> You received this message because you are subscribed to a topic in the
> Google Groups "elasticsearch" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/elasticsearch/RU5a2wSZCYc/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> elasticsearch+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/elasticsearch/9b3a7cf5-f3b7-45d7-881e-099c803f7bdc%40googlegroups.com<https://groups.google.com/d/msgid/elasticsearch/9b3a7cf5-f3b7-45d7-881e-099c803f7bdc%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
R R R

-- 
You received this message because you are subscribed to the Google Groups 
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elasticsearch+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elasticsearch/CAOLrPN6zfu6D1w4Sp-5w5OKaJ3B63yNXzJ7zamMFjFEv3_mAHg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to