如何在数据库中进行精确搜索
How to make exact search in Database
通常在 Whoosh phrase queries
中搜索得到精确的数学 using double quotes. It seems to work most but not all the time in bw2 (e.g. see here)。
db.search('"{}"'.format("Carbon dioxide, from soil or biomass stock"))
['Carbon dioxide, from soil or biomass stock' (kilogram, None, ('air','non-urban air or from high stacks')),
'Carbon dioxide, to soil or biomass stock' (kilogram, None, ('soil', agricultural')),
'Carbon dioxide, from soil or biomass stock' (kilogram, None, ('air', 'urban air close to ground')),
'Carbon dioxide, from soil or biomass stock' (kilogram, None, ('air',)),
'Carbon dioxide, to soil or biomass stock' (kilogram, None, ('soil', 'forestry')),
'Carbon dioxide, from soil or biomass stock' (kilogram, None, ('air', 'indoor')),
'Carbon dioxide, from soil or biomass stock' (kilogram, None, ('air', 'lower stratosphere + upper troposphere')),
'Carbon dioxide, to soil or biomass stock' (kilogram, None, ('soil', 'industrial')),
'Carbon dioxide, from soil or biomass stock' (kilogram, None, ('air', 'low population density, long-term')),
'Carbon dioxide, to soil or biomass stock' (kilogram, None, ('soil',))]
知道如何进行精确匹配搜索吗?
在 Whoosh 搜索索引中查找看似困难的内容的最简单方法是简单地跳过它,并过滤原始数据集,例如
[ds for ds in db if ds['name'].startswith('Carbon dioxide, from soil or biomass stock')]
添加任意复杂性非常容易,因为您只是添加 Python 个函数。
通常在 Whoosh phrase queries
中搜索得到精确的数学 using double quotes. It seems to work most but not all the time in bw2 (e.g. see here)。
db.search('"{}"'.format("Carbon dioxide, from soil or biomass stock"))
['Carbon dioxide, from soil or biomass stock' (kilogram, None, ('air','non-urban air or from high stacks')),
'Carbon dioxide, to soil or biomass stock' (kilogram, None, ('soil', agricultural')),
'Carbon dioxide, from soil or biomass stock' (kilogram, None, ('air', 'urban air close to ground')),
'Carbon dioxide, from soil or biomass stock' (kilogram, None, ('air',)),
'Carbon dioxide, to soil or biomass stock' (kilogram, None, ('soil', 'forestry')),
'Carbon dioxide, from soil or biomass stock' (kilogram, None, ('air', 'indoor')),
'Carbon dioxide, from soil or biomass stock' (kilogram, None, ('air', 'lower stratosphere + upper troposphere')),
'Carbon dioxide, to soil or biomass stock' (kilogram, None, ('soil', 'industrial')),
'Carbon dioxide, from soil or biomass stock' (kilogram, None, ('air', 'low population density, long-term')),
'Carbon dioxide, to soil or biomass stock' (kilogram, None, ('soil',))]
知道如何进行精确匹配搜索吗?
在 Whoosh 搜索索引中查找看似困难的内容的最简单方法是简单地跳过它,并过滤原始数据集,例如
[ds for ds in db if ds['name'].startswith('Carbon dioxide, from soil or biomass stock')]
添加任意复杂性非常容易,因为您只是添加 Python 个函数。