Example #1
0
        public override SchemaDescriptor SchemaFor(EntityType type, string[] entityTokens, Properties indexConfiguration, params string[] properties)
        {
            if (entityTokens.Length == 0)
            {
                throw new BadSchemaException("At least one " + (type == EntityType.NODE ? "label" : "relationship type") + " must be specified when creating a fulltext index.");
            }
            if (properties.Length == 0)
            {
                throw new BadSchemaException("At least one property name must be specified when creating a fulltext index.");
            }
            if (Arrays.asList(properties).contains(LuceneFulltextDocumentStructure.FIELD_ENTITY_ID))
            {
                throw new BadSchemaException("Unable to index the property, the name is reserved for internal use " + LuceneFulltextDocumentStructure.FIELD_ENTITY_ID);
            }
            int[] entityTokenIds = new int[entityTokens.Length];
            if (type == EntityType.NODE)
            {
                _tokenHolders.labelTokens().getOrCreateIds(entityTokens, entityTokenIds);
            }
            else
            {
                _tokenHolders.relationshipTypeTokens().getOrCreateIds(entityTokens, entityTokenIds);
            }
            int[] propertyIds = java.util.properties.Select(_tokenHolders.propertyKeyTokens().getOrCreateId).ToArray();

            SchemaDescriptor schema = SchemaDescriptorFactory.multiToken(entityTokenIds, type, propertyIds);

            indexConfiguration.putIfAbsent(FulltextIndexSettings.INDEX_CONFIG_ANALYZER, _defaultAnalyzerName);
            indexConfiguration.putIfAbsent(FulltextIndexSettings.INDEX_CONFIG_EVENTUALLY_CONSISTENT, _defaultEventuallyConsistentSetting);
            return(new FulltextSchemaDescriptor(schema, indexConfiguration));
        }
Example #2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public int labelGetOrCreateForName(String labelName) throws org.neo4j.internal.kernel.api.exceptions.schema.IllegalTokenNameException, org.neo4j.internal.kernel.api.exceptions.schema.TooManyLabelsException
        public override int LabelGetOrCreateForName(string labelName)
        {
            try
            {
                return(GetOrCreateForName(_tokenHolders.labelTokens(), labelName));
            }
            catch (TransactionFailureException e)
            {
                // Temporary workaround for the property store based label implementation.
                // Actual implementation should not depend on internal kernel exception messages like this.
                if (e.InnerException is UnderlyingStorageException && e.InnerException.Message.Equals("Id capacity exceeded"))
                {
                    throw new TooManyLabelsException(e);
                }
                throw e;
            }
        }
Example #3
0
 public override int LabelCount()
 {
     return(_tokenHolders.labelTokens().size());
 }