Register index actions for entity types with bidirectional attribute values.
348275
private void registerRefEntityIndexActions() {
    // bidirectional attribute: register indexing actions for other side
    getEntityType()
        .getMappedByAttributes()
        .forEach(
            mappedByAttr -> {
              EntityType refEntity = mappedByAttr.getRefEntity();
              indexActionRegisterService.register(refEntity, null);
            });

    getEntityType()
        .getInversedByAttributes()
        .forEach(
            inversedByAttr -> {
              EntityType refEntity = inversedByAttr.getRefEntity();
              indexActionRegisterService.register(refEntity, null);
            });
  }
273548
private function writeIndexes()
    {
        //Begin database batch
        $this->beginBatch();

        //Index all node entities
        foreach ($this->nodeEntities as $entity)
        {
            $this->index($entity);
        }

        //Index all relation entities
        foreach ($this->relationEntities as $entity)
        {
            $this->index($entity);
        }

        //Write all repository indexes
        foreach ($this->repositories as $repository)
        {
            $repository->writeIndex();
        }

        //Commit batch to the database
        $this->commitBatch();
    }
885182
private function initializeInternalTypes(): void
    {
        $phpToGraphQLMapping = [
            // PHP types
            'id' => Type::id(),
            'bool' => Type::boolean(),
            'int' => Type::int(),
            'float' => Type::float(),
            'string' => Type::string(),

            // Doctrine types
            'boolean' => Type::boolean(),
            'integer' => Type::int(),
            'smallint' => Type::int(),
            'bigint' => Type::int(),
            'decimal' => Type::string(),
            'text' => Type::string(),
        ];

        $this->types = $phpToGraphQLMapping;
        $this->registerInstance(new LogicalOperatorType());
        $this->registerInstance(new JoinTypeType());
        $this->registerInstance(new SortingOrderType());
    }
53153
def add_to_sources(self, action, doc_source):
        """"""
        mapping = self.sources.setdefault(action["_index"], {}).setdefault(
            action["_type"], {}
        )
        mapping[action["_id"]] = doc_source
435921
public void insertAttributeValueString(String attributeName, String value, int index) {

        m_entity.insertAttributeValue(attributeName, value, index);
    }
1165649
protected function indexAction() {
        try {
            $entity = $this->generateEntity();

            $query = new Index($this->request, $entity, $this->getQueryWhiteList());
            $this->response->setHeader('link', $query->generateLinks());
            /** @var ResultSet|ModelInterface[] $entities */
            $entities = $query->getResultSet();
            $entities = $this->filterEntities($entities);
            $this->indexActionInternal($entities);
            if($this->hasFlag((new FlagEnum(FlagEnum::PAGE_COUNTS)))) {
                $this->getOutputObject()->PageCounts = $query->generatePageCounts();
            }
        } catch(Exception $e) {
            $this->handleError($e);
        } catch(ValidationException $e) {
            $this->handleValidationError($e);
        } catch(AclException $e) {
            $this->handleAclError($e);
        } catch(CatchableException $e) {
            $this->handleCatchableError($e);
        }
    }
201937
public void handleValueChange(int valueIndex, String value) {

        changeEntityValue(value, valueIndex);
        CmsUndoRedoHandler handler = CmsUndoRedoHandler.getInstance();
        if (handler.isIntitalized()) {
            handler.addChange(m_entity.getId(), m_attributeName, valueIndex, ChangeType.value);
        }
    }
728345
private void addRelationshipIndex(EntityMetadata entityMetadata, Relationship relationship,
            Index<Relationship> relationshipIndex, MetamodelImpl metaModel)
    {
//        MetamodelImpl metaModel = (MetamodelImpl) kunderaMetadata.getApplicationMetadata().getMetamodel(
//                entityMetadata.getPersistenceUnit());

        // ID attribute has to be indexed first
        String idColumnName = ((AbstractAttribute) entityMetadata.getIdAttribute()).getJPAColumnName();
        relationshipIndex.add(relationship, idColumnName, relationship.getProperty(idColumnName));

        // Index all other fields, for whom indexing is enabled
        for (Attribute attribute : metaModel.entity(entityMetadata.getEntityClazz()).getSingularAttributes())
        {
            Field field = (Field) attribute.getJavaMember();
            if (!attribute.isCollection() && !attribute.isAssociation()
                    && entityMetadata.getIndexProperties().keySet().contains(field.getName()))
            {
                String columnName = ((AbstractAttribute) attribute).getJPAColumnName();
                relationshipIndex.add(relationship, columnName, relationship.getProperty(columnName));
            }
        }
    }
289359
private void checkIndexableClasses(SearchIntegrator searchFactory, Set<Class<?>> indexedEntities) {
      for (Class<?> c : indexedEntities) {
         if (searchFactory.getIndexBinding(new PojoIndexedTypeIdentifier(c)) == null) {
            throw log.classNotIndexable(c.getName());
         }
      }
   }
802014
def _index_and_mapping(self, namespace):
        """"""
        index, doc_type = namespace.split(".", 1)
        return index.lower(), doc_type
302941
protected function indexActionInternal($entities): void {
        $objects = [];
        foreach($entities as $entity) {
            $objects[] = $this->generateEntityAction($entity);
        }
        $outputObject = $this->getOutputObject();
        $blankEntity = $this->generateEntity();
        $outputObject->{$blankEntity->getEntityName() . 's'} = $objects;

        $this->setOutputObject($outputObject);
    }
1029839
def create_index(self, index, index_type=GEO2D):
        
        self.logger.info("Adding %s index to stores on attribute: %s" % (index_type, index))
        yield self.collection.create_index([(index, index_type)])
675095
public function buildMappingInformation(Index $index): MappingCollection
    {
        $this->lastMappingErrors = new Result();

        $mappings = new MappingCollection(MappingCollection::TYPE_ENTITY);

        /** @var NodeType $nodeType */
        foreach ($this->nodeTypeManager->getNodeTypes() as $nodeTypeName => $nodeType) {
            if ($nodeTypeName === 'unstructured' || $nodeType->isAbstract()) {
                continue;
            }

            $type = $index->findType($this->convertNodeTypeNameToMappingName($nodeTypeName));
            $mapping = new Mapping($type);
            $fullConfiguration = $nodeType->getFullConfiguration();
            if (isset($fullConfiguration['search']['elasticSearchMapping'])) {
                $fullMapping = $fullConfiguration['search']['elasticSearchMapping'];
                $this->migrateConfigurationForElasticVersion5($fullMapping);
                $mapping->setFullMapping($fullMapping);
            }

            // https://www.elastic.co/guide/en/elasticsearch/reference/5.4/dynamic-templates.html
            $mapping->addDynamicTemplate('dimensions', [
                'path_match' => '__dimensionCombinations.*',
                'match_mapping_type' => 'string',
                'mapping' => [
                    'type' => 'text'
                ]
            ]);
            $mapping->setPropertyByPath('__dimensionCombinationHash', [
                'type' => 'keyword'
            ]);

            foreach ($nodeType->getProperties() as $propertyName => $propertyConfiguration) {
                if (isset($propertyConfiguration['search']['elasticSearchMapping'])) {
                    if (is_array($propertyConfiguration['search']['elasticSearchMapping'])) {
                        $propertyMapping = $propertyConfiguration['search']['elasticSearchMapping'];
                        $this->migrateConfigurationForElasticVersion5($propertyMapping);
                        $mapping->setPropertyByPath($propertyName, $propertyMapping);
                    }
                } elseif (isset($propertyConfiguration['type'], $this->defaultConfigurationPerType[$propertyConfiguration['type']]['elasticSearchMapping'])) {
                    if (is_array($this->defaultConfigurationPerType[$propertyConfiguration['type']]['elasticSearchMapping'])) {
                        $mapping->setPropertyByPath($propertyName, $this->defaultConfigurationPerType[$propertyConfiguration['type']]['elasticSearchMapping']);
                    }
                } else {
                    $this->lastMappingErrors->addWarning(new Warning('Node Type "' . $nodeTypeName . '" - property "' . $propertyName . '": No ElasticSearch Mapping found.'));
                }
            }

            $mappings->add($mapping);
        }

        return $mappings;
    }
74963
public function beforeRenderIndexType()
    {
        if (!($this->_action() instanceof IndexAction)) {
            return;
        }

        $controller = $this->_controller();
        $controller->set('indexFinderScopes', $this->_getIndexFinderScopes());
        $controller->set('indexFormats', $this->_getIndexFormats());
        $controller->set('indexType', $this->_getIndexType());
        $controller->set('indexTitleField', $this->_getIndexTitleField());
        $controller->set('indexBodyField', $this->_getIndexBodyField());
        $controller->set('indexImageField', $this->_getIndexImageField());
        $controller->set('indexGalleryCssClasses', $this->_getIndexGalleryCssClasses());
    }
665319
public void register(InternalIndex index) {
        String[] components = index.getComponents();
        String attribute = components == null ? index.getName() : components[0];

        Record record = registry.get(attribute);
        if (record == null) {
            record = new Record();
            registry.put(attribute, record);
        }

        if (index.isOrdered()) {
            if (record.orderedWorseThan(index)) {
                record.ordered = components == null ? index : new FirstComponentDecorator(index);
            }
        } else {
            if (record.unorderedWorseThan(index)) {
                record.unordered = index;
            }
        }
    }
673407
@Override
    public void index(Class entityClazz, EntityMetadata m, Map<String, Object> values, Object parentId,
            Class parentClazz)
    {
        Set<String> indexNames = values.keySet();
        for (String idx_Name : indexNames)
        {
            Double value = (Double) values.get(idx_Name);
            Pipeline pipeLine = null;
            try
            {
                if (this.pipeLineOrConnection.getClass().isAssignableFrom(Jedis.class))
                {
                    pipeLine = ((Jedis) this.pipeLineOrConnection).pipelined();
                    pipeLine.zadd(idx_Name, value, parentId.toString());
                    // pipeLine.sync();
                }
                else
                {
                    ((Transaction) this.pipeLineOrConnection).zadd(idx_Name, value, parentId.toString());
                }
            }
            finally
            {
                if (pipeLine != null)
                {
                    pipeLine.sync();
                }
            }
        }

    }
910660
private void rebuildIndexOneEntity(String entityTypeId, String untypedEntityId) {
    LOG.trace("Indexing [{}].[{}]... ", entityTypeId, untypedEntityId);

    // convert entity id string to typed entity id
    EntityType entityType = dataService.getEntityType(entityTypeId);
    if (null != entityType) {
      Object entityId = getTypedValue(untypedEntityId, entityType.getIdAttribute());
      String entityFullName = entityType.getId();

      Entity actualEntity = dataService.findOneById(entityFullName, entityId);

      if (null == actualEntity) {
        // Delete
        LOG.debug("Index delete [{}].[{}].", entityFullName, entityId);
        indexService.deleteById(entityType, entityId);
        return;
      }

      boolean indexEntityExists = indexService.hasIndex(entityType);
      if (!indexEntityExists) {
        LOG.debug("Create mapping of repository [{}] because it was not exist yet", entityTypeId);
        indexService.createIndex(entityType);
      }

      LOG.debug("Index [{}].[{}].", entityTypeId, entityId);
      indexService.index(actualEntity.getEntityType(), actualEntity);
    } else {
      throw new MolgenisDataException("Unknown EntityType for entityTypeId: " + entityTypeId);
    }
  }