Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic collection name in loadElasticsearch command #2

Open
metmajer opened this issue May 10, 2014 · 11 comments
Open

Dynamic collection name in loadElasticsearch command #2

metmajer opened this issue May 10, 2014 · 11 comments
Assignees

Comments

@metmajer
Copy link

Thanks for providing this awesome lib! I am currently testing the loadElasticsearch command with the following configuration:

loadElasticsearch {
    collection: "myCollection"
    type: "myType"
    documentLoader: "REST" 
    elasticsearchConfig {
        hosts: ["localhost"]
    }
    ttl: 0
}

Is there a way to provide a dynamic collection name, e.g. with a date, or could you think of a simple solution to this?

Thanks and regards, Martin

@prog8
Copy link
Contributor

prog8 commented May 10, 2014

Hi, I think I can easily provide such a solution. It shouldn't take long time to implement it.

@prog8 prog8 self-assigned this May 10, 2014
@metmajer
Copy link
Author

That would be great. Could you already think of an example on how this could look like? I am still a newbie to morphlines and I cannot think of single command that would allow you to specify something like this:

loadElasticsearch {
    ...
    collector: "myIndexPrefix-${DATE}"
    ...
}

How would you approach that?

Cheers, Martin

@otisg
Copy link
Member

otisg commented May 10, 2014

Side comment: is this really referred to as "collection"? If yes, that's bad because ES doesn't have a notion of "collection" (SolrCloud does). ES uses the term "index".

@prog8
Copy link
Contributor

prog8 commented May 10, 2014

I think Martin writes about index. Morplines-ES use collection parameter and that's why Martin wrote that.
And you are right Otis that collection is not good word here. I'll change that name to "indexName" instead of collection.

@prog8
Copy link
Contributor

prog8 commented May 10, 2014

I pushed a change (collection -> index) here: 4dcb709

@metmajer
Copy link
Author

Btw, I have solved this issue for now by providing the values for the index and the type name in dedicated fields. The problem with this solution is, however, that these temporary fields will also be index into elasticsearch. Still hoping for a better solution.

@prog8
Copy link
Contributor

prog8 commented May 18, 2014

Hi Martin,
I'll prepare some patch that will let you prepare dynamic index names. I think by default it can be some TimeBasedIndexNameBuilder which will implement interface IndexNameBuilder. Name builder class should configurable and if you think there should be another name builder than time based you can just provide class implementing IndexNameBuilder to classpath and configuring it. Do you like that solution?

@metmajer
Copy link
Author

Hi Pawel,

I can't really imagine how this would look like in the end, maybe you can scribble an example configuration?
Honestly, I believe that the idea of reusing record fields to make up an index name is quite powerful.

Example:

loadElasticsearch {
    index: "@{indexName}"
    type: "@{indexType}"
    documentLoader: "REST" 
    elasticsearchConfig {
        hosts: ["localhost"]
    }
    ttl: 0
}

Since the fields 'indexName' and 'indexType' should not actually show up in the ES index, a configuration property 'ignoreFields' would come in handy to filter those fields out.

Example:

loadElasticsearch {
    ...
    ignoreFields: ["indexName", "indexType"]
    ...
}

Think this would be an easy solution that also does not require a proprietary naming solution.

What do you think?

Regards, Martin

@otisg
Copy link
Member

otisg commented Feb 11, 2015

@metmajer if you maybe have a patch, we'll take the PR :)

@fiserro
Copy link

fiserro commented Feb 24, 2015

I've made a pull request for this issue.
#6

@metmajer
Copy link
Author

@otisg Sorry, missed your comment. I haven't got the patch. Hope @fiserro's pull request helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants