public FuzzyQuery(Term term, int maxEdits, int prefixLength, int maxExpansions, boolean transpositions) {super(term.field());if (maxEdits < 0 || maxEdits > LevenshteinAutomata.MAXIMUM_SUPPORTED_DISTANCE) {throw new IllegalArgumentException("maxEdits must be between 0 and " + LevenshteinAutomata.MAXIMUM_SUPPORTED_DISTANCE);}if (prefixLength < 0) {throw new IllegalArgumentException("prefixLength cannot be negative.");}if (maxExpansions <= 0) {throw new IllegalArgumentException("maxExpansions must be positive.");}this.term = term;this.maxEdits = maxEdits;this.prefixLength = prefixLength;this.transpositions = transpositions;this.maxExpansions = maxExpansions;int[] codePoints = FuzzyTermsEnum.stringToUTF32(term.text());this.termLength = codePoints.length;this.automata = FuzzyTermsEnum.buildAutomata(term.text(), codePoints, prefixLength, transpositions, maxEdits);setRewriteMethod(new MultiTermQuery.TopTermsBlendedFreqScoringRewrite(maxExpansions));this.ramBytesUsed = calculateRamBytesUsed(term, this.automata);}

public FuzzyQuery ( Term term , int maxEdits , int prefixLength , int maxExpansions , boolean transpositions ) { super ( term . field ( ) ) ; if ( maxEdits < 0 || maxEdits > LevenshteinAutomata . MAXIMUM_SUPPORTED_DISTANCE ) { throw new IllegalArgumentException ( "maxEdits must be between 0 and " + LevenshteinAutomata . MAXIMUM_SUPPORTED_DISTANCE ) ; } if ( prefixLength < 0 ) { throw new IllegalArgumentException ( "prefixLength cannot be negative." ) ; } if ( maxExpansions <= 0 ) { throw new IllegalArgumentException ( "maxExpansions must be positive." ) ; } this . term = term ; this . maxEdits = maxEdits ; this . prefixLength = prefixLength ; this . transpositions = transpositions ; this . maxExpansions = maxExpansions ; int [ ] codePoints = FuzzyTermsEnum . stringToUTF32 ( term . text ( ) ) ; this . termLength = codePoints . length ; this . automata = FuzzyTermsEnum . buildAutomata ( term . text ( ) , codePoints , prefixLength , transpositions , maxEdits ) ; setRewriteMethod ( new MultiTermQuery . TopTermsBlendedFreqScoringRewrite ( maxExpansions ) ) ; this . ramBytesUsed = calculateRamBytesUsed ( term , this . automata ) ; }
public FuzzyQuery(Term term, int maxEdits, int prefixLength, int maxExpansions, bool transpositions): base(term.Field){if (maxEdits < 0 || maxEdits > LevenshteinAutomata.MAXIMUM_SUPPORTED_DISTANCE){throw new System.ArgumentException("maxEdits must be between 0 and " + LevenshteinAutomata.MAXIMUM_SUPPORTED_DISTANCE);}if (prefixLength < 0){throw new System.ArgumentException("prefixLength cannot be negative.");}if (maxExpansions < 0){throw new System.ArgumentException("maxExpansions cannot be negative.");}this.term = term;this.maxEdits = maxEdits;this.prefixLength = prefixLength;this.transpositions = transpositions;this.maxExpansions = maxExpansions;MultiTermRewriteMethod = new MultiTermQuery.TopTermsScoringBooleanQueryRewrite(maxExpansions);}
