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

add able to use Proc for settings #481

Merged
merged 2 commits into from
Mar 11, 2017
Merged

add able to use Proc for settings #481

merged 2 commits into from
Mar 11, 2017

Conversation

parallel588
Copy link
Contributor

@parallel588 parallel588 commented Mar 10, 2017

Hi Arkadiy (@pyromaniac), I added test.
about case where it may be use:
if we keep a synonyms/stopwords in db then in the settings we can use synonyms from db
for instance:

 class ProductsIndex < Chewy::Index
  settings proc {
    {
      analysis: {
        filter: {
          synonym: {
            type: 'synonym',
            ignore_case: true,
            synonyms: SearchSynonym.synonyms
          },
          
          custom_stop: {
            type: 'stop',
            stopwords: SearchStopWord.terms
          },
.....

and we can update settings after changes SearchSynonym.synonyms

   Chewy.client.indices.put_settings(
        index: productsIndex.index_name,
        body: {
          index: {
            analysis: {
              filter: {
                synonym: {
                  synonyms: SearchSynonym.synonyms
                }
              } } } }
      )

@parallel588
Copy link
Contributor Author

Hi @pyromaniac , I mistakenly closed the previous PR#440
Could you pleas check it PR?

@pyromaniac
Copy link
Contributor

Ah, here you are!

@@ -32,6 +32,27 @@
.to eq(settings: { number_of_nodes: 3, analysis: {} })
end

specify do
Synonyms = Class.new do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use stub_const here instead please?

@pyromaniac
Copy link
Contributor

Would appreciate if you will do a small fix, and I'll merge it right away, thanks!

@pyromaniac pyromaniac merged commit 1b73267 into toptal:master Mar 11, 2017
@pyromaniac
Copy link
Contributor

Great, thanks!

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

Successfully merging this pull request may close these issues.

2 participants