3 Replies Latest reply on Jan 31, 2012 9:17 AM by sannegrinovero

    Using SearchMapping in Infinispan 5.0.1

    ynusis

      I want to use:

       

      SearchMapping mapping = new SearchMapping();
      mapping.entity(MyOldObject.class).indexed().providedId()
            .property("name", ElementType.METHOD).field();
      DefaultCacheManager cacheManager = new DefaultCacheManager();
      cacheManager.getDefaultConfiguration().setIndexingEnabled(true);
      cacheManager.getDefaultConfiguration().setIndexLocalOnly(true);
      cacheManager.getDefaultConfiguration().getIndexingProperties().setProperty("hibernate.search.default.directory_provider", "ram");
      cacheManager.getDefaultConfiguration().getIndexingProperties().put(Environment.MODEL_MAPPING, mapping);
      Cache<String, MyOldObject> cache = cacheManager.getCache();
      

       

      to be able to index Classes where I can't add annotations. But this doesnt work

       

      SearchFactory searchFactory = Search.getSearchManager(cache).getSearchFactory();
      DirectoryProvider[] directoryProviders = searchFactory.getDirectoryProviders(MyOldObject.class);
      

      because directoryProviders is null. So my SearchMapping is not recognized at all.

       

      How can I use Infinispan Search if I ca not annotate the classes?

        • 1. Re: Using SearchMapping in Infinispan 5.0.1
          sannegrinovero

          Hi,

          I didn't document the SearchMapping usage with Query, and yes while I agree it could work we don't have tests for this either, so I'm not sure if some code in Infinispan would need to be changed to support the SearchMapping feature from Hibernate Search.

           

          Feel free to open a JIRA issue about this, I'll look into it as it makes perfect sense! If you have time to create a test case as well I'll appreciate the help.

           

          From the code in your first block it looks like you're setting indexing options after already having create the CacheManager.. that is very likely too late, all configuration should be defined before starting the CacheManager; the object returned by getDefaultConfiguration() should be immutable: in Infinispan 5.1 with the new configuration you wouldn't be allowed to make this mistakes as those setters are not exposed anymore. Could you try 5.1 using the ConfigurationBuilder instead to set those indexing options on the SearchManager before it's started?

          1 of 1 people found this helpful
          • 2. Re: Using SearchMapping in Infinispan 5.0.1
            ynusis

            I created an issue under https://issues.jboss.org/browse/ISPN-1820

            Thanks for your investigation!

            • 3. Re: Using SearchMapping in Infinispan 5.0.1
              sannegrinovero

              Thanks for the issue and the test!

              awesome