通常在Whoosh phrase queries
中搜索精确数学{@ 3}}。它似乎在bw2中工作最多但不是所有时间(例如using double quotes)。
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',))]
如何获得完全匹配搜索?
答案 0 :(得分:2)
在Whoosh搜索索引中找到似乎很难找到的东西的最简单方法是简单地跳过它,并过滤原始数据集,例如
[ds for ds in db if ds['name'].startswith('Carbon dioxide, from soil or biomass stock')]
添加任意复杂性非常容易,因为您只是添加了Python函数。