2

Hot to properly index SDN 5 dynamic @Properties?

Will the following property declaration work:

@Index(unique = false)
@Properties(prefix = NAME_PROPERTY_PREFIX)
private Map<String, String> nameProperties = new HashMap<>();

will all properties keys inside of nameProperties map be indexed separately? Please describe.

alexanoid
  • 24,051
  • 54
  • 210
  • 410

1 Answers1

3

This feature is not supported because the index creation, if auto index is enabled, will scan the classes on application start. Since there are no known fields (map keys) to be discovered when the class got scanned there is no index created.

Additionally when I tried your sample from above, I saw that an useless index on the property fields name (nameProperties) gets created that is never used in Neo4j.

meistermeier
  • 7,942
  • 2
  • 36
  • 45
  • Thanks for your answer. Are there any possible options in order to create indexes with the mentioned approach with dynamic properties? – alexanoid Nov 27 '17 at 11:18
  • The main idea behind the scene - is to localize my application in order to support any languages. For example currently, I have only `String name` property declared but also want to allow users any languages they want.. I don't know the set of these languages now.. for example, `name_en`, `name_fr`, `name_it` and so on... That's why I'd like to use dynamic properties for this purpose. – alexanoid Nov 27 '17 at 11:46
  • 1
    Is it really necessary to index this particular properties? It may be but for me this sounds somehow wrong. The basic idea of the index is to provide a "fast" entry to traverse the graph. In your setting you query all internationalised nodes by searching for their translated values!? If this is really what you want, my best guess is to explicit support some languages (thought experiment: or if there are a lot languages to support, and this is far from what I think is a good modeling approach and leads to more relationships, add a language node that holds the translations for a node.) – meistermeier Nov 27 '17 at 12:34
  • Thanks, you are absolutely right! I revisited my solution and the most appropriate way is to go with a relationship solution instead of trying to place everything into the single node. – alexanoid Nov 27 '17 at 13:05