Esempio n. 1
0
def do_reindex():
  """Update the full text search index."""

  indexer = get_indexer()
  indexer.delete_all_records(False)

  # Remove model base classes and non searchable objects
  excluded_models = {
      all_models.Directive,
      all_models.Option,
      all_models.SystemOrProcess,
      all_models.Role,
  }
  indexed_models = {model for model in all_models.all_models
                    if model_is_indexed(model)}

  indexed_models -= excluded_models

  for model in indexed_models:
    # pylint: disable=protected-access
    mapper_class = model._sa_class_manager.mapper.base_mapper.class_
    query = model.query.options(
        db.undefer_group(mapper_class.__name__ + '_complete'),
    )
    for query_chunk in generate_query_chunks(query):
      for instance in query_chunk:
        indexer.create_record(fts_record_for(instance), False)
      db.session.commit()

  reindex_snapshots()
Esempio n. 2
0
def do_reindex():
    """
  update the full text search index
  """

    indexer = get_indexer()
    indexer.delete_all_records(False)

    # Remove model base classes and non searchable objects
    excluded_models = {
        all_models.Directive, all_models.Option, all_models.SystemOrProcess
    }
    indexed_models = {
        model
        for model in all_models.all_models if model_is_indexed(model)
    }

    indexed_models -= excluded_models

    for model in indexed_models:
        mapper_class = model._sa_class_manager.mapper.base_mapper.class_
        query = model.query.options(
            db.undefer_group(mapper_class.__name__ + '_complete'), )
        for query_chunk in generate_query_chunks(query):
            for instance in query_chunk:
                indexer.create_record(fts_record_for(instance), False)
            db.session.commit()
Esempio n. 3
0
def do_reindex():
    """
  update the full text search index
  """

    indexer = get_indexer()
    indexer.delete_all_records(False)

    # Find all models then remove base classes
    #   (If we don't remove base classes, we get duplicates in the index.)
    inheritance_base_models = [
        all_models.Directive, all_models.SystemOrProcess
    ]
    models_ = set(all_models.all_models) - set(inheritance_base_models)
    models_ = [model for model in models_ if model_is_indexed(model)]

    for model in models_:
        mapper_class = model._sa_class_manager.mapper.base_mapper.class_
        query = model.query.options(
            db.undefer_group(mapper_class.__name__ + '_complete'), )
        for query_chunk in generate_query_chunks(query):
            for instance in query_chunk:
                indexer.create_record(fts_record_for(instance), False)
            db.session.commit()