Allow index name to be change dynamically #15

Closed
namlook opened this Issue Mar 25, 2013 · 5 comments

Comments

Projects
None yet
4 participants

namlook commented Mar 25, 2013

Hi,

For now, we can specify the index name via the annotation @indexname(name="foo"). I'd like to set it dynamically. Something like that:

obj2 = IndexTest(indexName="foo");
obj = IndexTest(indexName="bar");

and be able to search in a specific index with the same type:

IndexResults all = IndexTest.find.all(indexName="foo");
IndexResults all2 = IndexTest.find.all(indexName="bar");

Maybe it is possible to do it but I can't figure out how.

Contributor

mguillermin commented Mar 25, 2013

Hi,

It's not possible with the actual code, but it should be easy to do this by updating the Finder class.

We will try to look at that and add this new feature. You would be able to use something like this:

IndexResults all = IndexTest.find("foo").all();
IndexResults all2 = IndexTest.find("bar").all();

mguillermin was assigned Mar 25, 2013

Member

nboire commented Mar 25, 2013

Hi,

You can specific indexName when you call index() method and define multiple finder like this.

indexTest.index("foo");
indexTest.index("bar");

public static Finder<IndexTest> findFoo = new Finder<IndexTest>(IndexTest.class, "foo");
public static Finder<IndexTest> findBar = new Finder<IndexTest>(IndexTest.class, "bar");

After, you can request index via finder methods.

IndexResults allFoo = IndexTest.findFoo.all();
IndexResults allBar = IndexTest.findBar.all();

This feature is implement in 0.5-SNAPSHOT

Nelrohd commented Jul 8, 2013

Nice. Are you going to implement this feature in scala as well?

Contributor

mguillermin commented Jul 9, 2013

In Scala, you can already create multiple IndexableManager with different index values. Ex

object IndexTestManagerFoo extends IndexableManager[IndexTest] {
  override val index = "foo"
  ...
}

object IndexTestManagerBar extends IndexableManager[IndexTest] {
  override val index = "bar"
  ...
}

I think this offers approximately the same functionality as the Java version.

Nelrohd commented Jul 9, 2013

Hmm okay, maybe I could store them after in a Map where the key represent the index. Will see... Thank you!

mguillermin closed this Sep 5, 2013

mguillermin was unassigned by namlook Dec 5, 2014

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