3

So far I haven't found any samples of HOW the elastic.js client api (https://github.com/fullscale/elastic.js) can be used for indexing documents. There are some clues here & there but nothing concrete yet.

  • http://docs.fullscale.co/elasticjs/ejs.Document.html
  • Document ( index, type, id ): Object used to create, replace, update, and delete documents
  • Document > doIndex(fnCallBack): Stores a document in the given index and type. If no id is set, one is created during indexing.
  • Document > source (doc): Sets the source document.

Can anyone provide a sample snippet of code to show how an document object can be instantiated and used to index data?

Thanks!

Update # 1 (Sun Apr 21st, 2013 on 12:58pm CDT)

https://gist.github.com/pulkitsinghal/5430444

0

2 Answers 2

2

Your gist is correct.

You create ejs.Document objects specifying the index, type, and optionally the id of the document you want indexed. If you don't specify an id, elasticsearch will generate one for you.

You set the source to the json object you want indexed then call the doIndex method specifying a callback if needed. The node example does not index docs, but the angular and jquery examples show a basic example and can easily be used with the node client.

https://github.com/fullscale/elastic.js/blob/master/examples/angular/js/controllers.js#L30

Also have a peek at the tests:

https://github.com/fullscale/elastic.js/blob/master/tests/index_test.js#L265

1
  • 1
    It was a year ago, I can't even find the documentation on ejs.Document on the FullScale website ...
    – Romain
    Commented Apr 1, 2014 at 9:00
2

elastic.js nowadays only implements the Query DSL, so it can't be used for this scenario anymore. See this commit.

2

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.