當前位置: 首頁>>代碼示例>>Python>>正文


Python pymongo.TEXT屬性代碼示例

本文整理匯總了Python中pymongo.TEXT屬性的典型用法代碼示例。如果您正苦於以下問題:Python pymongo.TEXT屬性的具體用法?Python pymongo.TEXT怎麽用?Python pymongo.TEXT使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在pymongo的用法示例。


在下文中一共展示了pymongo.TEXT屬性的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: connect

# 需要導入模塊: import pymongo [as 別名]
# 或者: from pymongo import TEXT [as 別名]
def connect(self):
        self.init()

        # Create indexes
        self.files.create_index('md5')
        self.files.create_index('sha1')
        self.files.create_index('sha256')
        self.files.create_index([("$**", TEXT)], background=True)
        self.analysis.create_index('date')
        self.analysis.create_index([("$**", TEXT)], background=True) 
開發者ID:certsocietegenerale,項目名稱:fame,代碼行數:12,代碼來源:store.py

示例2: __init__

# 需要導入模塊: import pymongo [as 別名]
# 或者: from pymongo import TEXT [as 別名]
def __init__(self, function_result_status_persistance_conf, queue_name):
        self.function_result_status_persistance_conf = function_result_status_persistance_conf
        if self.function_result_status_persistance_conf.is_save_status:
            task_status_col = self.mongo_db_task_status.get_collection(queue_name)
            # params_str 如果很長,必須使用TEXt或HASHED索引。
            task_status_col.create_indexes([IndexModel([("insert_time_str", -1)]), IndexModel([("insert_time", -1)]),
                                            IndexModel([("params_str", pymongo.TEXT)]), IndexModel([("success", 1)])
                                            ], )
            task_status_col.create_index([("utime", 1)],
                                         expireAfterSeconds=function_result_status_persistance_conf.expire_seconds)  # 隻保留7天。
            self._mongo_bulk_write_helper = MongoBulkWriteHelper(task_status_col, 100, 2)
            self.task_status_col = task_status_col 
開發者ID:ydf0509,項目名稱:distributed_framework,代碼行數:14,代碼來源:base_consumer.py

示例3: init

# 需要導入模塊: import pymongo [as 別名]
# 或者: from pymongo import TEXT [as 別名]
def init(dataset_name, create_index=True):
    # Connection to DB system
    global dbc
    dbc = MongoClient(C.db_location)
    # Configure right DB
    global database
    database = dbc[dataset_name]
    global modeldb
    modeldb = database.columns
    # Create full text search index
    if create_index:
        print("Creating full-text search index")
        modeldb.create_index([('t_data', TEXT)])
        modeldb.create_index([("key", HASHED)]) 
開發者ID:mitdbg,項目名稱:aurum-datadiscovery,代碼行數:16,代碼來源:mongomodelstore.py

示例4: create_text_index

# 需要導入模塊: import pymongo [as 別名]
# 或者: from pymongo import TEXT [as 別名]
def create_text_index(collection, field_name, *args):
        # type: (pymongo.collection.Collection, str, SortOrder, bool) -> ()
        MongoRepository.create_index(collection, field_name, pymongo.TEXT) 
開發者ID:accelero-cloud,項目名稱:appkernel,代碼行數:5,代碼來源:repository.py

示例5: explicit_key

# 需要導入模塊: import pymongo [as 別名]
# 或者: from pymongo import TEXT [as 別名]
def explicit_key(index):
    if isinstance(index, (list, tuple)):
        assert len(index) == 2, 'Must be a (`key`, `direction`) tuple'
        return index
    if index.startswith('+'):
        return (index[1:], ASCENDING)
    if index.startswith('-'):
        return (index[1:], DESCENDING)
    if index.startswith('$'):
        return (index[1:], TEXT)
    if index.startswith('#'):
        return (index[1:], HASHED)
    return (index, ASCENDING) 
開發者ID:Scille,項目名稱:umongo,代碼行數:15,代碼來源:indexes.py

示例6: __init__

# 需要導入模塊: import pymongo [as 別名]
# 或者: from pymongo import TEXT [as 別名]
def __init__(self, config):
        #*** Required for BaseClass:
        self.config = config
        #*** Set up Logging with inherited base class method:
        self.configure_logging(__name__, "switches_logging_level_s",
                                       "switches_logging_level_c")

        #*** Set up database collections:
        #*** Get parameters from config:
        mongo_addr = config.get_value("mongo_addr")
        mongo_port = config.get_value("mongo_port")
        mongo_dbname = config.get_value("mongo_dbname")

        #*** Start mongodb:
        self.logger.info("Connecting to MongoDB database...")
        mongo_client = MongoClient(mongo_addr, mongo_port)

        #*** Connect to MongoDB nmeta database:
        db_nmeta = mongo_client[mongo_dbname]

        #*** Delete (drop) previous switches collection if it exists:
        self.logger.debug("Deleting previous switches MongoDB collection...")
        db_nmeta.switches_col.drop()

        #*** Create the switches collection:
        self.switches_col = db_nmeta.create_collection('switches_col')

        #*** Index dpid key to improve look-up performance:
        self.switches_col.create_index([('dpid', pymongo.TEXT)], unique=False)

        #*** Get max bytes of new flow packets to send to controller from
        #*** config file:
        self.miss_send_len = config.get_value("miss_send_len")
        if self.miss_send_len < 1500:
            self.logger.info("Be aware that setting "
                             "miss_send_len to less than a full size packet "
                             "may result in errors due to truncation. "
                             "Configured value is %s bytes",
                             self.miss_send_len)
        #*** Tell switch how to handle fragments (see OpenFlow spec):
        self.ofpc_frag = config.get_value("ofpc_frag")

        #*** Flow mod cookie value offset indicates flow session direction:
        self.offset = config.get_value("flow_mod_cookie_reverse_offset")

        #*** Dictionary of the instances of the Switch class,
        #***  key is the switch DPID which is assumed to be unique:
        self.switches = {} 
開發者ID:mattjhayes,項目名稱:nmeta,代碼行數:50,代碼來源:switches.py


注:本文中的pymongo.TEXT屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。