Partager via


Syntax of Query Language Dialect 2

Note

Indexing Service is no longer supported as of Windows XP and is unavailable for use as of Windows 8. Instead, use Windows Search for client side search and Microsoft Search Server Express for server side search.

 

The following EBNF production rules define the syntax of the extensible Indexing Service query language, Query Dialect 2. Terminal symbols are case insensitive: or, OR, Or, and oR are equivalent. The production rules give terminal symbols in lowercase only.

Query =                                                (* start symbol *)

( [ Query ( or { · }- | | )] AndTerm )

| ( not { · }- | ! ) Query ;

AndTerm =

NearTerm

| ( ( not { · }- | ! ) PropTerm )

| ( AndTerm ( and { · }- | & ) [ ( not { · }- | ! ) ] NearTerm ) ;

NearTerm =

CoerceTerm

| ( NearTerm ( {near { · }- | ~ ) CoerceTerm )

| ( NearTerm NearElement } CoerceTerm ) ;

PropTerm =

( Property [ = ] Regex [ {/prop} ] )

| ( Property Operator Value [ {/prop} ] ) ;

CoerceTerm =

( [ Generate ] NestTerm [ {/generate} ] )

| ( [ Generate ] {/coerce} [ Generate ] NestTerm [ {/generate} ] )

| ( [ Generate ] Weight [ Generate ] NestTerm [ {/generate} ] ) ;

NearElement =

White

| ,

| ( dist { · } = { · } Digits )

| ( unit { · } = { · } ( ›word | sent | par | chap ) ) ;

Property =

[ LongPropName | ShortPropName ] ;

(* The following rule only prepares for the query engine, which does *)

(* the final parsing. See Pattern-Matching Queries for the full syntax. *)

Regex =

( {regex} " [ AnyExceptQuote ] " {/regex} )

| ( {regex} [ AnyExceptCurlyOpen ] {/regex} )

| ( {regex} [ [ AnyExceptNewline ] | [ AnyExceptNewline ] ] {/regex} ) ;

Operator =

= | != | > | >= | < | <= | ^a | ^s

| ( = { · }^s | ^s { · } = )

| ( != { · } ^s | ^s { · } != )

| ( > { · } ^s | ^s { · } > )

| ( >= { · } ^s | ^s { · } >= )

| ( < { · } ^s | ^s { · } < )

| ( <= { · } ^s | ^s { · } <= )

| ( ^s { · } ^a )

| ( ^s { · } ^s )

| ( ^a { · } = )

| ( ^a { · } != )

| ( ^a { · } > )

| ( ^a { · } >= )

| ( ^a { · } < )

| ( ^a { · } <= )

| ( ^a { · } ^a )

| ( ^a { · } ^s ) ;

Value =

Phrase

| Freetext

| VectorValue ;

Generate =

( {generate { · }- method { · } = { · } prefix { · } } )

| ( {generate { · }- method { · } = { · } inflect { · } } ) ;

NestTerm =

VectorTerm

| Term

| ( ( Query ) ) ;

Weight =

{weight { · }- value { · } = { · } ( 0 | 1 | ( 0. { DecimalDigit } ) | ( 1. { 0 } ) | ( . { DecimalDigit }- ) ) ;

LongPropName =

( {prop { · }- name { · } = { · } " [ AnyExceptQuote ] " { · } } )

| ( {prop { · }- name { · } = { · } AnyExceptQuoteCurlyCloseSpace [ AnyExceptCurlyClose ] } ) ;

ShortPropName =

( ( @ | $ | # ) " AnyExceptQuote " )

| ( ( @ | $ | # ) AnyExceptExcluded ) ;

Phrase =

( LongPhrase | ShortPhrase ) [ * | ** ] ;

Freetext =

( LongFreetext | ShortFreetext ) [ * | ** ] ;

VectorValue =

EmptyVector

| SingletVector

| MultiVector ) ;

LongPhrase =

( {phrase} { · } " [ AnyExceptQuote ] " { · } {/phrase} )

| ( {phrase} [ AnyExceptCurlyOpen ] {/phrase} ) ;

ShortPhrase =

( " [ AnyExceptQuote ] " )

| ( AnyExceptMany [ AnyExceptOp ] [ · ] ) ;

LongFreetext =

( {freetext} { · } " [ AnyExceptQuote ] " { · } {/freetext} )

| ( {freetext} [ AnyExceptCurlyOpen ] {/freetext} ) ;

ShortFreetext =

AnyExceptMany [ AnyExceptOp ] [ · ] ;

VectorTerm =

VectorSpec {/vector} ;

Term =

PropTerm

| ( Property [ contains { · }- ] Phrase [ {/prop} ] )

| ( Property [ contains { · }- ] Generate Phrase [ {/generate} ] [ {/prop} ) ]

| ( Property [ contains { · }- ] Query )

| ( Property [ contains { · }- ] Freetext [ {/prop} ] ) ;

EmptyVector =

( ) ;

SingletVector =

( ( Phrase ) )

| ( ( Freetext ) ) ;

MultiVector =

( VectorElement VectorElement )

| ( MultiVector VectorElement ) ;

VectorSpec =

( VectorMethod {ve} Query )

| ( VectorSpec {ve} Query ) ;

VectorElement =

White

| ;

| ( " [ AnyExceptQuote ] " )

| ( AnyExceptVector [ AnyExceptSemiClose ] ( ; | ) ) ) ;

VectorMethod =

( {vector { · }- rankmethod { · } = { · } " [ AnyExceptQuote ] " { · } } )

| ( {vector { · }- rankmethod { · } = [ AnyExceptCurlyClose ] } ) ;

Digits =

{ DecimalDigit }- ;

DecimalDigit =

0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 ;

White =

· | \t | \n | \f | \r ;

AnyExceptQuote =

? Any character sequence ? - " ;        (* quoted " ( = "" ) is OK *)

AnyExceptNewline =

? Any character sequence ? - \n ;

AnyExceptCurlyOpen =

? Any character sequence ? - { ;

AnyExceptCurlyClose =

? Any character sequence ? - } ;

AnyExceptSemiClose =

? Any character sequence ? - ( ; | ) ) ;

AnyExceptQuoteCurlyCloseSpace =

? Any character sequence ? - ( " | } | · ) ;

AnyExceptVector =

? Any character sequence ? - ( " | ; | · ) ;

AnyExceptOp =

? Any character sequence ? - ( & | ~ | | | { | ) | · ) ;

AnyExceptExcluded =

? Any character sequence ? - ( " | · | < | > | = | ! | & | | | ~ | ^ ) ;

AnyExceptMany =

? Any character sequence ? - ( # | $ | @ | ~ | & | | | < | > | = | ! | ^| * | " | ( | ) | { | · ) ;