/** Creates new WildcardTermEnum */
    WildcardTermEnum::WildcardTermEnum(IndexReader* reader, Term* term):
	    FilteredTermEnum(),
		__term(_CL_POINTER(term)),
		fieldMatch(false),
		_endEnum(false)
    {
       
		pre = stringDuplicate(term->text());

		const TCHAR* sidx = _tcschr( pre, LUCENE_WILDCARDTERMENUM_WILDCARD_STRING );
		const TCHAR* cidx = _tcschr( pre, LUCENE_WILDCARDTERMENUM_WILDCARD_CHAR );
		const TCHAR* tidx = sidx;
		if (tidx == NULL) 
			tidx = cidx;
		else if ( cidx && cidx > pre) 
			tidx = min(sidx, cidx);
		CND_PRECONDITION(tidx != NULL, "tidx==NULL");
		int32_t idx = (int32_t)(tidx - pre);
		preLen = idx;
		CND_PRECONDITION(preLen<term->textLength(), "preLen >= term->textLength()");
		pre[preLen]=0; //trim end

		Term* t = _CLNEW Term(__term, pre);
		setEnum( reader->terms(t) );
		_CLDECDELETE(t);
  }
Ejemplo n.º 2
0
 PrefixTermEnum::PrefixTermEnum(IndexReaderPtr reader, TermPtr prefix)
 {
     this->_endEnum = false;
     this->prefix = prefix;
     
     setEnum(reader->terms(newLucene<Term>(prefix->field(), prefix->text())));
 }
Ejemplo n.º 3
0
	FuzzyTermEnum::FuzzyTermEnum(IndexReader* reader, Term* term, float_t minSimilarity, size_t _prefixLength):
		FilteredTermEnum(),d(NULL),dLen(0),_similarity(0),_endEnum(false),searchTerm(_CL_POINTER(term)),
		text(NULL),textLen(0),prefix(NULL)/* ISH: was STRDUP_TtoT(LUCENE_BLANK_STRING)*/,prefixLength(0),
		minimumSimilarity(minSimilarity)
	{
		CND_PRECONDITION(term != NULL,"term is NULL");

		if (minSimilarity >= 1.0f)
			_CLTHROWA(CL_ERR_IllegalArgument,"minimumSimilarity cannot be greater than or equal to 1");
		else if (minSimilarity < 0.0f)
			_CLTHROWA(CL_ERR_IllegalArgument,"minimumSimilarity cannot be less than 0");

		scale_factor = 1.0f / (1.0f - minimumSimilarity); // only now we are safe from a division by zero
		//TODO: this.field = searchTerm.field();

		//The prefix could be longer than the word.
		//It's kind of silly though.  It means we must match the entire word.
		const size_t fullSearchTermLength = searchTerm->textLength();
		const size_t realPrefixLength = _prefixLength > fullSearchTermLength ? fullSearchTermLength : _prefixLength;

		text = STRDUP_TtoT(searchTerm->text() + realPrefixLength);
		textLen = fullSearchTermLength - realPrefixLength;

		prefix = _CL_NEWARRAY(TCHAR,realPrefixLength+1);
		_tcsncpy(prefix, searchTerm->text(), realPrefixLength);
		prefix[realPrefixLength]='\0';
        prefixLength = realPrefixLength;

		initializeMaxDistances();

		Term* trm = _CLNEW Term(searchTerm->field(), prefix); // _CLNEW Term(term, prefix); -- not intern'd?
		setEnum(reader->terms(trm));
		_CLLDECDELETE(trm);


		/* LEGACY:
		//Initialize e to NULL
		e          = NULL;
		eWidth     = 0;
		eHeight    = 0;

		if(prefixLength > 0 && prefixLength < textLen){
		this->prefixLength = prefixLength;

		prefix = _CL_NEWARRAY(TCHAR,prefixLength+1);
		_tcsncpy(prefix,text,prefixLength);
		prefix[prefixLength]='\0';

		textLen = prefixLength;
		text[textLen]='\0';
		}
		*/
	}
Ejemplo n.º 4
0
WildcardTermEnum::WildcardTermEnum(const IndexReaderPtr& reader, const TermPtr& term) {
    _endEnum = false;
    searchTerm = term;
    field = searchTerm->field();
    String searchTermText(searchTerm->text());

    String::size_type sidx = searchTermText.find(WILDCARD_STRING);
    String::size_type cidx = searchTermText.find(WILDCARD_CHAR);
    String::size_type idx = sidx;
    if (idx == String::npos) {
        idx = cidx;
    } else if (cidx != String::npos) {
        idx = std::min(idx, cidx);
    }
    pre = idx != String::npos ? searchTerm->text().substr(0, idx) : L"";

    preLen = pre.length();
    text = searchTermText.substr(preLen);
    setEnum(reader->terms(newLucene<Term>(searchTerm->field(), pre)));
}
 TermRangeTermEnum::TermRangeTermEnum(IndexReaderPtr reader, const String& field, StringValue lowerTermText, 
                                      StringValue upperTermText, bool includeLower, bool includeUpper, CollatorPtr collator)
 {
     this->collator = collator;
     this->_endEnum = false;
     this->upperTermText = upperTermText;
     this->lowerTermText = lowerTermText;
     this->includeLower = includeLower;
     this->includeUpper = includeUpper;
     this->field = field;
     
     // do a little bit of normalization: open ended range queries should always be inclusive.
     if (VariantUtils::isNull(this->lowerTermText))
         this->includeLower = true;
     
     if (VariantUtils::isNull(this->upperTermText))
         this->includeUpper = true;
     
     String startTermText(collator ? L"" : VariantUtils::get<String>(this->lowerTermText));
     setEnum(reader->terms(newLucene<Term>(this->field, startTermText)));
 }
Ejemplo n.º 6
0
		//! Default constructor
		CEnumAttribute::CEnumAttribute(const c8* name, const c8* value,
				const c8* const * literals)
		{
			Name = name;
			setEnum(value, literals);
		}