Boolean operators Java – search index बनाएं और faceted search
Implementing a powerful खोज अनुभव in Java can feel overwhelming, especially when you need to search index Java बनाएं that supports boolean operators Java for faceted and complex queries. In this tutorial we’ll walk through setting up GroupDocs.Search for Java, building an index, adding documents, and crafting both simple faceted searches and sophisticated multi‑criteria queries that use Boolean logic. By the end you’ll understand how to leverage content search Java, filename search Java, and even update index Java operations to keep your data fresh.
त्वरित उत्तर
- फ़ैसिटेड खोज क्या है? फ़ाइल प्रकार या तिथि जैसी पूर्वनिर्धारित श्रेणियों द्वारा परिणामों को फ़िल्टर करने का एक तरीका।
- मैं search index Java कैसे बनाऊँ? फ़ोल्डर की ओर संकेत करने वाला
Indexऑब्जेक्ट इनिशियलाइज़ करें और दस्तावेज़ जोड़ें। - क्या मैं कई मानदंडों को boolean operators के साथ संयोजित कर सकता हूँ? हाँ—ऑब्जेक्ट‑आधारित क्वेरीज़ या टेक्स्ट क्वेरी में Boolean operators का उपयोग करें।
- क्या मुझे लाइसेंस चाहिए? विकास के लिए एक मुफ्त ट्रायल काम करता है; एक व्यावसायिक लाइसेंस सीमाओं को हटा देता है।
- कौन सा IDE सबसे अच्छा है? कोई भी Java IDE (IntelliJ IDEA, Eclipse, NetBeans) ठीक काम करता है।
“create search index java” क्या है?
search index Java बनाना मतलब डिस्क‑आधारित संरचना बनाना है जो दस्तावेज़ टेक्स्ट और मेटाडेटा को संग्रहीत करती है, जिससे क्वेरीज़ के माध्यम से मिलते‑जुलते दस्तावेज़ों को तुरंत प्राप्त किया जा सके। इंडेक्स शब्दों को दस्तावेज़ पहचानकर्ताओं से मैप करता है, तेज़ लुकअप को सपोर्ट करता है, और फ़ाइलों के बदलने पर क्रमिक रूप से अपडेट किया जा सकता है, जिससे शक्तिशाली खोज सुविधाओं की नींव बनती है।
faceted और जटिल क्वेरीज़ के लिए GroupDocs.Search क्यों उपयोग करें?
GroupDocs.Search for Java बिल्ट‑इन फ़ैसिटिंग, Boolean क्वेरी सपोर्ट, और हाई‑परफ़ॉर्मेंस इंडेक्सिंग प्रदान करता है जो 10 million दस्तावेज़ तक संभाल सकता है जबकि सामान्य सर्वर हार्डवेयर पर क्वेरी लेटेंसी 200 ms से कम रखता है। यह आउट‑ऑफ़‑द‑बॉक्स फ़ील्ड फ़िल्टर, समृद्ध क्वेरी भाषा, और शुद्ध‑Java संगतता देता है, जिससे एंटरप्राइज़‑स्केल खोज परिदृश्यों के लिए यह आदर्श बनता है।
पूर्वापेक्षाएँ
- JDK 8 या नया आपके IDE में स्थापित और कॉन्फ़िगर किया गया।
- Maven (या Gradle) निर्भरता प्रबंधन के लिए।
- GroupDocs.Search for Java ≥ 25.4।
- Java OOP अवधारणाओं और Maven प्रोजेक्ट संरचना की बुनियादी परिचितता।
GroupDocs.Search for Java सेटअप करना
Maven सेटअप
अपने pom.xml फ़ाइल में रिपॉज़िटरी और डिपेंडेंसी जोड़ें:
<repositories>
<repository>
<id>repository.groupdocs.com</id>
<name>GroupDocs Repository</name>
<url>https://releases.groupdocs.com/search/java/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.groupdocs</groupId>
<artifactId>groupdocs-search</artifactId>
<version>25.4</version>
</dependency>
</dependencies>
सीधे डाउनलोड
वैकल्पिक रूप से, आधिकारिक रिलीज़ पेज से नवीनतम JAR डाउनलोड करें:
GroupDocs.Search for Java रिलीज़
लाइसेंस प्राप्ति
पूर्ण कार्यक्षमता अनलॉक करने के लिए:
- Free trial – विकास और परीक्षण के लिए उपयुक्त।
- Temporary evaluation license – ट्रायल सीमाओं को बढ़ाता है।
- Commercial license – उत्पादन उपयोग के लिए सभी प्रतिबंध हटाता है।
बुनियादी इनिशियलाइज़ेशन और सेटअप
Index क्लास वह कोर कंपोनेंट है जो डिस्क पर संग्रहीत खोज योग्य इंडेक्स को दर्शाता है। निम्न स्निपेट दिखाता है कि कैसे Index क्लास को इंस्टैंसिएट करके search index Java बनाएं:
import com.groupdocs.search.Index;
public class SearchSetup {
public static void main(String[] args) {
String indexFolder = "YOUR_OUTPUT_DIRECTORY/AdvancedUsage/Searching/FacetedSearch/SimpleFacetedSearch";
// Create an instance of Index – this creates the on‑disk index
Index index = new Index(indexFolder);
System.out.println("GroupDocs.Search initialized successfully!");
}
}
With the index ready, we can move on to real‑world faceted and complex queries.
boolean operators java का उपयोग कैसे करें – सरल फ़ैसिटेड खोज
Load your index, add documents, and issue a field query; the two‑step pattern lets you retrieve facet counts and filtered results in a single call. This approach gives users an intuitive way to narrow results by categories such as file type, author, or custom metadata.
चरण 1: इंडेक्स बनाएं
First, point the Index to a folder where the index files will be stored.
import com.groupdocs.search.Index;
String indexFolder = "YOUR_OUTPUT_DIRECTORY/AdvancedUsage/Searching/FacetedSearch/SimpleFacetedSearch";
Index index = new Index(indexFolder);
चरण 2: इंडेक्स में दस्तावेज़ जोड़ें
Tell GroupDocs.Search where your source documents live. All supported file types (PDF, DOCX, TXT, etc.) will be indexed automatically.
import com.groupdocs.search.Index;
String documentsFolder = "YOUR_DOCUMENT_DIRECTORY";
// Adding documents to the index
index.add(documentsFolder);
चरण 3: कंटेंट फ़ील्ड में टेक्स्ट क्वेरी के साथ खोज करें
A quick text query filters by the content field. The syntax content: Pellentesque limits results to documents containing the word Pellentesque in their body text.
import com.groupdocs.search.results.SearchResult;
String query1 = "content: Pellentesque";
SearchResult result1 = index.search(query1);
// Output search results
System.out.println("Documents found (query 1): " + result1.getDocumentCount());
चरण 4: ऑब्जेक्ट क्वेरी का उपयोग करके खोज करें
Object‑based queries give you fine‑grained control. Here we build a word query, wrap it in a field query, and execute it.
import com.groupdocs.search.SearchQuery;
import com.groupdocs.search.options.CommonFieldNames;
SearchQuery wordQuery = SearchQuery.createWordQuery("Pellentesque");
SearchQuery fieldQuery = SearchQuery.createFieldQuery(CommonFieldNames.Content, wordQuery);
SearchResult result2 = index.search(fieldQuery);
// Output search results
System.out.println("Documents found (query 2): " + result2.getDocumentCount());
boolean operators java का उपयोग कैसे करें – जटिल क्वेरी खोज
To execute a complex query, combine multiple field conditions with AND/OR/NOT operators, and optionally include phrase searches. You can specify each condition using field queries, nest them with Boolean operators, and control relevance with boosting, allowing you to retrieve only the most relevant documents that satisfy all required criteria.
चरण 1: जटिल क्वेरीज़ के लिए इंडेक्स बनाएं
Reuse the same folder structure; you can share the index across both simple and complex scenarios.
String indexFolder = "YOUR_OUTPUT_DIRECTORY/AdvancedUsage/Searching/FacetedSearch/ComplexQuery";
Index index = new Index(indexFolder);
index.add(documentsFolder);
चरण 2: टेक्स्ट क्वेरी के साथ खोज करें
The following query looks for files named lorem and ipsum or content containing either of two exact phrases.
import com.groupdocs.search.results.SearchResult;
String query1 = "(filename: (lorem AND ipsum)) OR (content: (\"lectus eu aliquam\" OR \"dignissim turpis\"))";
SearchResult result1 = index.search(query1);
// Output search results
class SearchResult {
public int getDocumentCount() {
// Implementation here
return 0; // Placeholder
}
}
System.out.println("Documents found (complex text query): " + result1.getDocumentCount());
चरण 3: ऑब्जेक्ट क्वेरी के साथ खोज करें
Object‑based construction mirrors the textual query but offers type safety and IDE assistance.
import com.groupdocs.search.SearchQuery;
SearchQuery word6Query = SearchQuery.createWordQuery("lorem");
SearchQuery word7Query = SearchQuery.createWordQuery("ipsum");
// Constructing AND, OR queries for filename field
SearchQuery andQuery = SearchQuery.createAndQuery(word6Query, word7Query);
SearchQuery filenameQuery = SearchQuery.createFieldQuery(CommonFieldNames.FileName, andQuery);
// Content search using OR query with phrases
SearchQuery phrase1Query = SearchQuery.createPhraseSearchQuery("lectus", "eu", "aliquam");
SearchQuery phrase2Query = SearchQuery.createPhraseSearchQuery("dignissim", "turpis");
SearchQuery contentQuery = SearchQuery.createFieldQuery(CommonFieldNames.Content,
SearchQuery.createOrQuery(phrase1Query, phrase2Query));
// Final root query combining filename and content queries
SearchQuery rootQuery = SearchQuery.createOrQuery(filenameQuery, contentQuery);
SearchResult result2 = index.search(rootQuery);
// Output search results
System.out.println("Documents found (complex object query): " + result2.getDocumentCount());
फ़ैसिटेड और जटिल खोजों के व्यावहारिक अनुप्रयोग
| परिदृश्य | फ़ैसिटिंग कैसे मदद करती है | उदाहरण क्वेरी |
|---|---|---|
| ई‑कॉमर्स कैटलॉग | श्रेणी, कीमत, ब्रांड द्वारा फ़िल्टर करें | category: Electronics AND price:[100 TO 500] |
| कानूनी दस्तावेज़ रिपॉज़िटरी | केस नंबर, अधिकार क्षेत्र द्वारा संकीर्ण करें | caseNumber: 2023-045 AND jurisdiction: "California" |
| शोध अभिलेख | लेखक, प्रकाशन वर्ष, कीवर्ड्स को संयोजित करें | (author: "Doe") AND (year: 2022) AND (keywords: "machine learning") |
| एंटरप्राइज़ इंट्रानेट | फ़ाइल प्रकार और विभाग द्वारा खोजें | filetype: pdf AND department: HR |
These examples illustrate why mastering boolean operators java and filename search java techniques is a game‑changer for any data‑intensive application.
सामान्य कठिनाइयाँ और समस्या निवारण
The SearchResult object contains the documents that match a query and provides access to their relevance scores and highlighted fragments.
The CommonFieldNames class defines standard field names such as Content and FileName used throughout the API.
- Empty results – सत्यापित करें कि दस्तावेज़ सफलतापूर्वक जोड़े गए हैं (
index.getDocumentCount()मदद कर सकता है)। - Stale index – फ़ाइलें जोड़ने या हटाने के बाद,
index.update()कॉल करें ताकि update index java किया जा सके और इंडेक्स सिंक में रहे। - Incorrect field names – टाइपो से बचने के लिए
CommonFieldNamesकॉन्स्टेंट्स (Content,FileName, आदि) का उपयोग करें। - Performance bottlenecks – बड़े संग्रह के लिए,
index.setCacheSize()सक्षम करने या इंडेक्स फ़ोल्डर के लिए समर्पित SSD उपयोग करने पर विचार करें। - Missing highlights – highlight search results java करने के लिए,
SearchResult.getFragments()के माध्यम से मिलते हुए फ्रैगमेंट प्राप्त करें (यहाँ नहीं दिखाया गया है लेकिन API में उपलब्ध है)।
अक्सर पूछे जाने वाले प्रश्न
Q: क्या मैं GroupDocs.Search को Spring Boot के साथ उपयोग कर सकता हूँ?
A: बिल्कुल। Maven डिपेंडेंसी जोड़ें, इंडेक्स को Spring bean के रूप में कॉन्फ़िगर करें, और जहाँ भी खोज क्षमताओं की आवश्यकता हो वहाँ इंजेक्ट करें।
Q: क्या लाइब्रेरी कस्टम मेटाडेटा फ़ील्ड्स को सपोर्ट करती है?
A: हाँ – आप इंडेक्सिंग के दौरान यूज़र‑डिफ़ाइंड फ़ील्ड्स जोड़ सकते हैं और फिर उन पर फ़ैसिट कर सकते हैं।
Q: इंडेक्स कितना बड़ा हो सकता है?
A: डिस्क‑आधारित इंडेक्स 10 million दस्तावेज़ तक संभाल सकता है; बस पर्याप्त स्टोरेज सुनिश्चित करें और कैश सेटिंग्स मॉनिटर करें।
Q: क्या परिणामों को प्रासंगिकता के आधार पर रैंक करने का कोई तरीका है?
A: GroupDocs.Search स्वचालित रूप से मैचों को स्कोर देता है; आप स्कोर SearchResult.getDocument(i).getScore() के माध्यम से प्राप्त कर सकते हैं।
Q: यदि मैं एन्क्रिप्टेड PDFs को इंडेक्स करता हूँ तो क्या होता है?
A: दस्तावेज़ जोड़ते समय पासवर्ड प्रदान करें: index.add(filePath, password)।
निष्कर्ष
अब आप GroupDocs.Search के साथ search index Java बनाना, दस्तावेज़ जोड़ना, और सरल फ़ैसिटेड क्वेरीज़ तथा उन्नत Boolean खोजों को boolean operators java का उपयोग करके बनाने में सहज महसूस करेंगे। ये क्षमताएँ आपको ई‑कॉमर्स प्लेटफ़ॉर्म से लेकर एंटरप्राइज़ नॉलेज बेस तक विभिन्न अनुप्रयोगों में तेज़, सटीक और उपयोगकर्ता‑मित्र खोज अनुभव प्रदान करने में सक्षम बनाती हैं।
Ready for the next step? Explore GroupDocs.Search’s advanced features such as highlighting, suggestions, and real‑time indexing to further boost your application’s search power.
Last Updated: 2026-08-26
Tested With: GroupDocs.Search 25.4 for Java
Author: GroupDocs