本文整理匯總了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)
示例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
示例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)])
示例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)
示例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)
示例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 = {}