包括弹性搜索查询中的排除过滤器

时间:2016-11-17 17:04:03

标签: elasticsearch

我是elasticsearch的新手,我想知道在预先形成查询时是否有办法包含或排除过滤器。这样我只编写一个查询而不是多个查询。

1 个答案:

答案 0 :(得分:0)

是的,您可以使用shutil.rmtree中的shutil.rmtree标记来执行此操作。类似的东西:

import shutil
import os
import stat

def remove_readonly(func, path, excinfo):
    os.chmod(path, stat.S_IWRITE)
    func(path)

try:
    #os.chmod is used to turn off Read-Only attribute
    os.chmod("Q:/-----.vbs", stat.S_IWRITE)
    #os.remove is used to remove individual files
    os.remove("Q:/-----.vbs")
except:
    pass

#shutil.rmtree is used to remove entire directories
#remove traces of file
try:
    shutil.rmtree("Q:/FolderToRemove1", onerror=remove_readonly)
except:
    pass

try:
    shutil.rmtree("Q:/FolderToRemove2", onerror=remove_readonly)
except:
    pass

try:
    shutil.rmtree("Q:/FolderToRemove3", onerror=remove_readonly)
except:
    pass

try:
    shutil.rmtree("Q:/FolderToRemove4", onerror=remove_readonly)
except:
    pass

try:
    shutil.rmtree("Q:/FolderToRemove5", onerror=remove_readonly)
except:
    pass

try:
    shutil.rmtree("C:/Users/mhill/Desktop/screenshots", onerror=remove_readonly)
except:
    pass

但是你可能也想看看post filtering。当您在filter内外进行过滤时,性能可能会有所不同。这SO可能很方便。在结构化数据方面,您可以使用filter context