
MarkLogic Server Search Developer’s Guide 1Application Developer’s Guide MarkLogic 10 May, 2019 Last Revised: 10.0-7, June, 2021 Copyright © 2021 MarkLogic Corporation. All rights reserved. MarkLogic Server Table of Contents Table of Contents Search Developer’s Guide 1.0 Developing Search Applications in MarkLogic Server ...............................22 1.1 Overview of Search Features in MarkLogic Server .............................................22 1.1.1 High Performance Full Text Search .........................................................22 1.1.2 APIs for Multiple Programming Languages .............................................23 1.1.3 Support for Multiple Query Styles ............................................................24 1.1.4 Support for Multiple Query Types ............................................................26 1.1.5 Full XPath Search Support in XQuery .....................................................28 1.1.6 Lexicon and Range Index-Based APIs .....................................................28 1.1.7 Stemming, Wildcard, Spelling, and Much More Functionality ................28 1.1.8 Alerting API and Built-Ins ........................................................................28 1.2 Where to Find Search Information .......................................................................29 2.0 Search API: Understanding and Using ........................................................30 2.1 Understanding the Search API ..............................................................................30 2.1.1 Making the Search API Available to Your Application ...........................31 2.1.2 Simple search:search Example and Response Output ..............................31 2.1.3 Automatic Query Text Parsing and Grammar ..........................................32 2.1.4 Constrained Searches and Faceted Navigation .........................................34 2.1.5 Built-In Snippetting ..................................................................................36 2.1.6 Search Term Completion ..........................................................................36 2.1.7 Search Customization Via Options and Extensions .................................36 2.1.8 Speed and Accuracy ..................................................................................37 2.2 Controlling a Search With Query Options ............................................................37 2.3 Search Term Completion Using search:suggest ...................................................38 2.3.1 default-suggestion-source Option .............................................................38 2.3.2 Choose Suggestions With the suggestion-source Option .........................39 2.3.3 Use Multiple Query Text Inputs to search:suggest ...................................40 2.3.4 Make Suggestions Based on Cursor Position ...........................................41 2.3.5 search:suggest Examples ..........................................................................41 2.4 Creating a Custom Constraint ...............................................................................42 2.4.1 Implementing the parse Function .............................................................42 2.4.2 Implementing the start-facet Function ......................................................45 2.4.3 Implementing the finish-facet Function ....................................................46 2.4.4 Example: Creating a Simple Custom Constraint ......................................47 2.4.5 Example: Creating a Custom Constraint for Structured Queries ..............48 2.4.6 Example: Creating a Custom Constraint Geospatial Facet .......................50 2.5 Search Grammar ...................................................................................................53 2.6 Returning Lexicon Values With search:values .....................................................54 MarkLogic 10—May, 2019 Search Developer’s Guide—Page 2 MarkLogic Server Table of Contents 2.6.1 Specifying the Input Lexicons ..................................................................54 2.6.2 Constraining and Filtering Your Results ..................................................55 2.6.3 Example: Using a Query to Constrain Results .........................................56 2.6.4 Example: Filtering with Starting Value, Limit, and Page Length ............58 2.6.5 Example: Finding Value Co-Occurrences ................................................60 2.6.6 Additional Interfaces .................................................................................60 2.7 JSON Support in the Search API ..........................................................................60 2.8 More Search API Examples ..................................................................................62 2.8.1 Buckets Example ......................................................................................62 2.8.2 Computed Buckets Example .....................................................................64 2.8.3 Sort Order Example ..................................................................................66 3.0 Searching Using String Queries ...................................................................67 3.1 String Query Overview .........................................................................................67 3.2 The Default String Query Grammar .....................................................................68 3.2.1 Query Components and Operators ............................................................68 3.2.2 Operator Precedence .................................................................................71 3.2.3 Using Relational Operators on Constraints ..............................................72 3.2.4 String Query Examples .............................................................................73 4.0 Searching Using Structured Queries ............................................................74 4.1 Structured Query Overview ..................................................................................74 4.2 Structured Query Concepts ...................................................................................75 4.2.1 Major Query Categories ............................................................................76 4.2.2 Understanding the Difference Between Term and Word Queries ............77 4.2.3 Understanding Containment .....................................................................77 4.2.4 Text Match Semantics ..............................................................................79 4.2.5 Structured Query Sub-Query Taxonomy ..................................................80 4.3 Constructing a Structured Query ..........................................................................81 4.4 Syntax Summary ...................................................................................................82 4.5 Examples of Structured Queries ...........................................................................83 4.5.1 Example: Simple Structured Search .........................................................83 4.5.2 Example: Structured Search With Constraint References as Text ...........84 4.5.3 Example: Structured Search With Constraint References ........................85 4.5.4 Example: Structured Search on Key-Value Metadata Fields ...................86 4.6 Syntax Reference ..................................................................................................87 4.6.1 query .........................................................................................................89 4.6.2 term-query .................................................................................................91 4.6.3 and-query ..................................................................................................93 4.6.4 or-query .....................................................................................................94 4.6.5 and-not-query ............................................................................................96 4.6.6 not-query ...................................................................................................98 4.6.7 not-in-query ..............................................................................................99 4.6.8 true-query ................................................................................................101 4.6.9 false-query ..............................................................................................102 MarkLogic 10—May, 2019 Search Developer’s Guide—Page 3 MarkLogic Server Table of Contents 4.6.10 near-query ...............................................................................................103 4.6.11 boost-query .............................................................................................105 4.6.12 properties-fragment-query ......................................................................107 4.6.13 directory-query ........................................................................................110 4.6.14 collection-query ......................................................................................112 4.6.15 container-query .......................................................................................113 4.6.16 document-query ......................................................................................115 4.6.17 document-fragment-query ......................................................................116
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages958 Page
-
File Size-