public SpanQuery getSpanQuery(Element e) throws ParserException {String fieldName = DOMUtils.getAttributeWithInheritanceOrFail(e, "fieldName");String value = DOMUtils.getNonBlankTextOrFail(e);List<SpanQuery> clausesList = new ArrayList<>();try (TokenStream ts = analyzer.tokenStream(fieldName, value)) {TermToBytesRefAttribute termAtt = ts.addAttribute(TermToBytesRefAttribute.class);ts.reset();while (ts.incrementToken()) {SpanTermQuery stq = new SpanTermQuery(new Term(fieldName, BytesRef.deepCopyOf(termAtt.getBytesRef())));clausesList.add(stq);}ts.end();SpanOrQuery soq = new SpanOrQuery(clausesList.toArray(new SpanQuery[clausesList.size()]));float boost = DOMUtils.getAttribute(e, "boost", 1.0f);return new SpanBoostQuery(soq, boost);}catch (IOException ioe) {throw new ParserException("IOException parsing value:" + value);}}

public SpanQuery getSpanQuery ( Element e ) throws ParserException { String fieldName = DOMUtils . getAttributeWithInheritanceOrFail ( e , "fieldName" ) ; String value = DOMUtils . getNonBlankTextOrFail ( e ) ; List < SpanQuery > clausesList = new ArrayList < > ( ) ; try ( TokenStream ts = analyzer . tokenStream ( fieldName , value ) ) { TermToBytesRefAttribute termAtt = ts . addAttribute ( TermToBytesRefAttribute . class ) ; ts . reset ( ) ; while ( ts . incrementToken ( ) ) { SpanTermQuery stq = new SpanTermQuery ( new Term ( fieldName , BytesRef . deepCopyOf ( termAtt . getBytesRef ( ) ) ) ) ; clausesList . add ( stq ) ; } ts . end ( ) ; SpanOrQuery soq = new SpanOrQuery ( clausesList . toArray ( new SpanQuery [ clausesList . size ( ) ] ) ) ; float boost = DOMUtils . getAttribute ( e , "boost" , 1.0f ) ; return new SpanBoostQuery ( soq , boost ) ; } catch ( IOException ioe ) { throw new ParserException ( "IOException parsing value:" + value ) ; } }
public override SpanQuery GetSpanQuery(XmlElement e){string fieldName = DOMUtils.GetAttributeWithInheritanceOrFail(e, "fieldName");string value = DOMUtils.GetNonBlankTextOrFail(e);List<SpanQuery> clausesList = new List<SpanQuery>();TokenStream ts = null;try{ts = analyzer.GetTokenStream(fieldName, value);ITermToBytesRefAttribute termAtt = ts.AddAttribute<ITermToBytesRefAttribute>();BytesRef bytes = termAtt.BytesRef;ts.Reset();while (ts.IncrementToken()){termAtt.FillBytesRef();SpanTermQuery stq = new SpanTermQuery(new Term(fieldName, BytesRef.DeepCopyOf(bytes)));clausesList.Add(stq);}ts.End();SpanOrQuery soq = new SpanOrQuery(clausesList.ToArray());soq.Boost = DOMUtils.GetAttribute(e, "boost", 1.0f);return soq;}catch (IOException ioe){throw new ParserException("IOException parsing value:" + value);}finally{IOUtils.DisposeWhileHandlingException(ts);}}
