-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_search_wrapper.py
More file actions
37 lines (27 loc) · 1.25 KB
/
run_search_wrapper.py
File metadata and controls
37 lines (27 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import os
import sys
# Load coreclr first
from pythonnet import load
load("coreclr")
import clr
# Add folder with the wrapper library and dependencies to the system path
dll_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), "dlls"))
sys.path.append(dll_dir)
# Add reference to the wrapper library
clr.AddReference("GroupDocs.Search.Wrapper") # will search for GroupDocs.Search.Wrapper.dll
clr.AddReference("GroupDocs.Search") # will search for GroupDocs.Search.dll
# Import the wrapper class
from GroupDocs.Search.Wrapper import SearchWrapper
from GroupDocs.Search.Results import FoundDocument
# Call the method from Wrapper to create index
SearchWrapper.Step1_BuildSearchQuery("index", "files")
# Call the method from Wrapper to provide actual search
documents = SearchWrapper.Step2_Query("index", "warehouse")
for doc in documents:
print("Document Info:", doc.DocumentInfo.FilePath) # may itself be another .NET object
print("Relevance:", doc.Relevance)
print("Occurrences:", doc.OccurrenceCount)
print("Terms:", list(doc.Terms)) # convert string[] to Python list
print("Attributes:", list(doc.Attributes)) # same for string[]
print("ToString():", doc.ToString())
print("-" * 60)