Adding Types to an Index #76

Open
russellseymour opened this Issue Aug 6, 2013 · 1 comment

Comments

Projects
None yet
2 participants
@russellseymour

Good morning,

Last night I stumbled across the SherlockPHP library and I think it will be very good for my application. I am looking to move from using a combination of Mongo and Solr to just using ElasticSearch and I have been looking for a library to help me with this and I think I may have found it :-).

I wonder if you could help me with a couple of things:

  1. Is it possible to use an array, or JSON, to describe the mappings for a type? I know this can be done for a query but I was wondering (and hoping) it can be done for the MappingBuilder as well.
  2. Can a type be added to the index after the index has been created? I attempted to use something like:
// create a mapping
$mapping = \Sherlock\Sherlock::mappingBuilder('settings') -> String() -> field("name");

// Apply the mapping to the index
$index -> mappings($mapping);

$index -> update();

But this came back with an 'Undefined offset' error, which I suspect is to do with the way I applied the mapping to the index.

Finally it is stated on the GitHub page that version 0.2 will be released soon and it has some breaking changes, are these documented anywhere? I want to use this library but may hold off for a while of there are lots of breaking changes.

Lastly I apologise for cross posting this to Google Groups and GutHub issues, I was not sure which one would be more active.

Thanks very much, Russell

@polyfractal

This comment has been minimized.

Show comment Hide comment
@polyfractal

polyfractal Aug 7, 2013

Owner

Hey, sorry for the slow reply. Been travelling a lot for work.

  1. Unfortunately, there isn't a way to define an entire mapping with an array right now. You can do per-type arrays:
$mapping = \Sherlock\Sherlock::mappingBuilder('settings') -> String($myArray);

But cannot supply an array for the entire mapping. I agree that this would be a useful feature, but it doesn't exist yet :(

  1. Theoretically, you should be able to do something like this:
$index = $sherlock->index('test_mappings');
$index->type("new_type")->mappings($mapping);
$response = $index->updateMapping();

If you're using syntax like that and its throwing errors, let me know - it's probably a bug.

  1. No list of breaking changes for 0.2, but it will be considerable. Much of the API is being reorganized to be more consistent. "Leaf API" calls (like each individual query type) will remain unchanged, but the query-builder part to generate complex queries is changing a lot. That said, I don't see 0.2 being released for a few more months. It's temporarily on hold due to waiting for an third-party library (which is going to be released soon). Once that library is released, I can resume work on the 0.2 branch.
Owner

polyfractal commented Aug 7, 2013

Hey, sorry for the slow reply. Been travelling a lot for work.

  1. Unfortunately, there isn't a way to define an entire mapping with an array right now. You can do per-type arrays:
$mapping = \Sherlock\Sherlock::mappingBuilder('settings') -> String($myArray);

But cannot supply an array for the entire mapping. I agree that this would be a useful feature, but it doesn't exist yet :(

  1. Theoretically, you should be able to do something like this:
$index = $sherlock->index('test_mappings');
$index->type("new_type")->mappings($mapping);
$response = $index->updateMapping();

If you're using syntax like that and its throwing errors, let me know - it's probably a bug.

  1. No list of breaking changes for 0.2, but it will be considerable. Much of the API is being reorganized to be more consistent. "Leaf API" calls (like each individual query type) will remain unchanged, but the query-builder part to generate complex queries is changing a lot. That said, I don't see 0.2 being released for a few more months. It's temporarily on hold due to waiting for an third-party library (which is going to be released soon). Once that library is released, I can resume work on the 0.2 branch.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment