เรามีความยินดีที่จะแจ้งการเปิดตัว GroupDocs.Search for Python v26.10 ซึ่งพร้อมให้ใช้งานตั้งแต่ พฤศจิกายน 2026 นี่คือการเปิดตัวครั้งแรกของผลิตภัณฑ์ โดยนำเอาฟังก์ชันเต็มรูปแบบของเอนจิ้น GroupDocs.Search 26.10 มาสู่ผู้พัฒนา Python ทำให้สามารถสร้างและดูแลดัชนีข้อความเต็มบนโฟลเดอร์ของเอกสาร — รวมถึง PDF, Word, Excel, PowerPoint, อีเมล, eBook, ไฟล์บีบอัดและรูปแบบอื่น ๆ อีกมากกว่า (กว่า 80 รูปแบบ) — และค้นหาโดยใช้ประเภทคำค้นขั้นสูง: คำสำคัญ, วลี, ตัวแทนหลายค่า, regex, fuzzy, boolean, faceted, และการค้นหาช่วงวันที่ การปล่อยนี้รองรับ Python 3.5–3.14 บน Windows x64, Linux x64 (glibc 2.27+), และ macOS 13+ (Intel และ Apple Silicon) พร้อมฝัง runtime ของ .NET 10.0.14
มีอะไรใหม่ในรุ่นนี้
- [Feature] การเปิดตัวครั้งแรกของ GroupDocs.Search for Python ผ่าน .NET (SEARCHPYTHONNET-40)
การเปลี่ยนแปลง API สาธารณะ
นี่คือการปล่อยครั้งแรก ดังนั้นจึงไม่มีอะไรให้อัปเกรด API นี้สอดคล้องกับ GroupDocs.Search for .NET 26.10: คลาสยังคงใช้ชื่อ .NET เดิม ในขณะที่เมธอด, คุณสมบัติและพารามิเตอร์จะเขียนเป็น snake_case (Index.Search คือ index.search, SearchResult.DocumentCount คือ result.document_count) และสมาชิกของ enum จะเป็นตัวพิมพ์ใหญ่ (OutputFormat.HTML) การกำหนดแอตทริบิวต์ที่คลาสไม่มีจะทำให้เกิด AttributeError พร้อมคำแนะนำ “Did you mean” แทนการสร้างแอตทริบิวต์เฉพาะ Python ที่เอนจิ้นไม่เคยเห็น
โมดูล
groupdocs.search:Index,IndexSettings,IndexRepository,IndexUpdater,SearchQuery,Extractor,License,Metered,GroupDocsSearchException,LicenseError,CancellationTokenSource.groupdocs.search.options:IndexingOptions,SearchOptions,FuzzySearchOptions,SimilarityLevel,UpdateOptions,HighlightOptions,OutputFormat,SeparateProcessOptions,ImageSearchOptions.groupdocs.search.results:SearchResult,FoundDocument,FoundDocumentField,DocumentInfo,FileType,FormatFamily.groupdocs.search.highlighters:DocumentHighlighter,FragmentHighlighter.groupdocs.search.common:FileOutputAdapter,StringOutputAdapter,StreamOutputAdapter,Document,DocumentField,ExtractedData,FileLogger,AttributeChangeBatch.groupdocs.search.dictionaries:SynonymDictionary,HomophoneDictionary,StopWordDictionary,SpellingCorrector,AliasDictionary,CharacterReplacementPair.groupdocs.search.events:EventHub,FileIndexingEventArgs,IndexErrorEventArgs,OperationProgressEventArgs,PasswordRequiredEventArgs.groupdocs.search.exceptions:SearchException,LicenseRestrictionException.groupdocs.search.scaling:SearchNetworkNode,Indexer,Searcher.groupdocs.search.scaling.configuring:Configuration,Configurator,TcpSettings.
ฟีเจอร์ใหม่
ดัชนีเอกสารและค้นหา
Index(folder) สร้างดัชนีในโฟลเดอร์ หรือเปิดดัชนีที่มีอยู่แล้ว add() ทำการดัชนีโฟลเดอร์, ไฟล์, รายการพาธ, สตรีม หรือข้อมูลที่สกัดออกมา และ search() รับคำค้นในภาษาคำค้นของ GroupDocs.Search: คำสำคัญ, วลีในเครื่องหมายคำพูด, ตัวแทนหลายค่า (? สำหรับอักขระหนึ่ง, ?(1~5) สำหรับหนึ่งถึงห้า), regular expressions หลัง ^, AND, OR และ NOT, คำค้นฟิลด์เช่น content: Bern หรือ filename: einstein, รวมถึงช่วงวันที่และตัวเลข SearchQuery สร้างคำค้นเดียวกันในรูปแบบอ็อบเจกต์
from groupdocs.search import Index
with Index("./index") as index: # creates the index folder, or opens it
index.add("./documents") # indexes every supported file in the folder
for query in ["relativity", '"theory of relativity"', "relativ?ty",
"^relativ.*", "Einstein AND NOT Newton", "content: Bern"]:
result = index.search(query)
print("%-26s %d documents, %d occurrences"
% (query, result.document_count, result.occurrence_count))
การค้นหาแบบ Fuzzy, synonym และ word-form
การค้นหาแบบ fuzzy รองรับข้อผิดพลาดจากการพิมพ์และ OCR การค้นหา synonym, homophone และ word-form ขยายคำค้นผ่านพจนานุกรมภาษาอังกฤษในตัว ซึ่ง index.dictionaries ให้คุณแก้ไขได้ และการแก้ไขการสะกดและแปลงแป้นพิมพ์ก็เป็นตัวเลือกการค้นหาเช่นกัน
from groupdocs.search import Index
from groupdocs.search.options import SearchOptions, SimilarityLevel
with Index("./index") as index:
index.add("./documents")
fuzzy = SearchOptions()
fuzzy.fuzzy_search.enabled = True
fuzzy.fuzzy_search.fuzzy_algorithm = SimilarityLevel(0.8) # 0.0 (loose) .. 1.0 (strict)
print("relativty:", index.search("relativty").document_count,
"->", index.search("relativty", fuzzy).document_count)
synonyms = SearchOptions()
synonyms.use_synonym_search = True
print("picture:", index.search("picture").document_count,
"->", index.search("picture", synonyms).document_count)
word_forms = SearchOptions()
word_forms.use_word_forms_search = True
print("letter:", index.search("letter").document_count,
"->", index.search("letter", word_forms).document_count)
ไฮไลท์สิ่งที่พบ
DocumentHighlighter เขียนเอกสารทั้งหมดพร้อมทำเครื่องหมายคำที่พบ, ส่วน FragmentHighlighter จะทำเฉพาะส่วนที่อยู่รอบ ๆ คำที่พบ ทั้งในรูปแบบ HTML หรือ plain text สามารถส่งออกไปยังไฟล์, สตริง หรืออ็อบเจกต์ไฟล์ไบนารีได้
from groupdocs.search import Index
from groupdocs.search.common import FileOutputAdapter
from groupdocs.search.highlighters import DocumentHighlighter
from groupdocs.search.options import OutputFormat
with Index("./index") as index:
index.add("./documents")
result = index.search("relativity")
if result.document_count > 0:
found = result.get_found_document(0)
adapter = FileOutputAdapter(OutputFormat.HTML, "./highlighted.html")
index.highlight(found, DocumentHighlighter(adapter))
print(found.document_info.file_path, "-> highlighted.html")
.NET events เป็นตัวจัดการใน Python
เหตุการณ์ทุกอย่างของดัชนีเป็นเหตุการณ์ใน Python: สมัครด้วย += และยกเลิกด้วย -= ตัวจัดการสามารถข้ามเอกสาร, ใส่แท็กด้วยแอตทริบิวต์ หรือให้รหัสผ่านได้ และจะติดตามความคืบหน้า, ข้อผิดพลาดและขั้นตอนของการทำดัชนีและการค้นหา
from groupdocs.search import Index
skipped = []
def on_file_indexing(sender, args):
if args.document_full_path.endswith(".zip"):
args.skip_indexing = True # leave archives out of the index
skipped.append(args.document_full_path)
with Index("./index") as index:
index.events.file_indexing += on_file_indexing
index.add("./documents")
index.events.file_indexing -= on_file_indexing
print(len(index.get_indexed_documents()), "documents indexed,", len(skipped), "archives skipped")
วัตถุ Python สำหรับจุดขยายของเินจิ้น
ตัวสกัดข้อความแบบกำหนดเองสำหรับรูปแบบของคุณเอง, ตัวบันทึก, ตัวแยกคำ, ผู้ให้บริการรูปแบบคำ, ตัวโหลดเอกสารและคอนเนคเตอร์ OCR เป็นอ็อบเจกต์หรือฟังก์ชัน Python ธรรมดา ซึ่งเอนจิ้นจะเรียกผ่านอินเทอร์เฟซของมัน
from groupdocs.search import Index, IndexSettings
class LogExtractor(object):
"""Text of .log files, which the engine does not read on its own."""
extensions = [".log"]
def get_fields(self, source): # a file path, or the engine's stream
if isinstance(source, str):
with open(source, encoding="utf-8") as f:
text = f.read()
else:
text = source.read().decode("utf-8")
return [("Content", text)]
settings = IndexSettings()
settings.custom_extractors.add(LogExtractor())
with Index("./log-index", settings) as index:
index.add("./logs")
print(index.search("quota").document_count, "log file(s) mention a quota")
รักษาดัชนีให้เป็นปัจจุบัน
ดัชนีคือโฟลเดอร์: สร้างครั้งเดียวแล้วเปิดใหม่ในรันต่อไป update() ทำการดัชนีใหม่เฉพาะเอกสารที่เปลี่ยนแปลงตั้งแต่ add() หรือ update() ครั้งล่าสุด, optimize() จะรวมส่วนของดัชนี, และ delete() จะลบเอกสารตามพาธ
from groupdocs.search import Index
with Index("./index") as index:
index.add("./documents")
# ... files in ./documents are added, changed or removed ...
index.update() # re-indexes only what changed
index.optimize() # merges index segments so searches stay fast
print(len(index.get_indexed_documents()), "documents in the index")
ใบอนุญาตจากสภาพแวดล้อม
ตั้งค่า GROUPDOCS_LIC_PATH ให้เป็นพาธหรือ URL ของไฟล์ใบอนุญาต และใบอนุญาตจะถูกนำไปใช้ในการเรียกครั้งแรกเข้าสู่เอนจิ้น; License().set_license(path) ทำเช่นเดียวกันในโค้ด ใบอนุญาตที่ไม่สามารถนำไปใช้ได้จะทำให้เกิด LicenseError ตั้งแต่การเรียกครั้งแรก แทนการกลับไปใช้โหมดประเมินค่า หากไม่มีใบอนุญาต ดัชนีจะจำกัดไม่เกิน 100 เอกสารและสามารถอ่านเอกสารที่พบแรก 10 ฉบับของการค้นหาได้เท่านั้น
export GROUPDOCS_LIC_PATH="/path/to/GroupDocs.Search.lic"
ตัวอย่างโค้ด
ดูส่วน “ดัชนีเอกสารและค้นหา”, “การค้นหาแบบ Fuzzy, synonym และ word-form”, “ไฮไลท์สิ่งที่พบ”, “.NET events เป็นตัวจัดการใน Python”, “วัตถุ Python สำหรับจุดขยายของเินจิ้น”, และ “รักษาดัชนีให้เป็นปัจจุบัน” ด้านบนสำหรับตัวอย่างโค้ดที่ทำงานได้
วิธีรับการอัปเดต
PyPI
- Package: groupdocs-search-net 26.10.0
- Install command:
pip install groupdocs-search-net==26.10.0
ดาวน์โหลดโดยตรง
ดาวน์โหลด wheel สำหรับแพลตฟอร์มของคุณจากหน้า GroupDocs.Search for Python via .NET 26.10 แล้วติดตั้งไฟล์:
- Windows x64:
pip install groupdocs_search_net-26.10.0-py3-none-win_amd64.whl - Linux x64:
pip install groupdocs_search_net-26.10.0-py3-none-manylinux_2_27_x86_64.whl - macOS Intel:
pip install groupdocs_search_net-26.10.0-py3-none-macosx_13_0_x86_64.whl - macOS Apple Silicon:
pip install groupdocs_search_net-26.10.0-py3-none-macosx_13_0_arm64.whl