Example #1
0
static void add_sort_test_data(SortTestData *std, IndexWriter *iw)
{
    Document *doc = doc_new();
    doc_add_field(doc, df_add_data(df_new(search), std->search));
    doc_add_field(doc, df_add_data(df_new(string), std->string));
    doc_add_field(doc, df_add_data(df_new(integer), std->integer));
    doc_add_field(doc, df_add_data(df_new(flt), std->flt));

    sscanf(std->flt, "%f", &doc->boost);

    iw_add_doc(iw, doc);
    doc_destroy(doc);
}
Example #2
0
File: ind.c Project: dustin/ferret
void index_add_string(Index *self, char *str)
{
    Document *doc = doc_new();
    doc_add_field(doc, df_add_data(df_new(self->def_field), estrdup(str)));
    index_add_doc(self, doc);
    doc_destroy(doc);
}
Example #3
0
File: ind.c Project: dustin/ferret
void index_add_array(Index *self, char **fields)
{
    int i;
    Document *doc = doc_new();
    for (i = 0; i < ary_size(fields); i++) {
        doc_add_field(doc, df_add_data(df_new(self->def_field),
                                       estrdup(fields[i])));
    }
    index_add_doc(self, doc);
    doc_destroy(doc);
}
Example #4
0
void prepare_filter_index(Store *store)
{
    int i;
    IndexWriter *iw;
    FieldInfos *fis = fis_new(STORE_YES, INDEX_YES, TERM_VECTOR_NO);

    num      = intern("num");
    date     = intern("date");
    flipflop = intern("flipflop");

    struct FilterData data[FILTER_DOCS_SIZE] = {
        {"0", "20040601", "on"},
        {"1", "20041001", "off"},
        {"2", "20051101", "on"},
        {"3", "20041201", "off"},
        {"4", "20051101", "on"},
        {"5", "20041201", "off"},
        {"6", "20050101", "on"},
        {"7", "20040701", "off"},
        {"8", "20050301", "on"},
        {"9", "20050401", "off"}
    };

    index_create(store, fis);
    fis_deref(fis);

    iw = iw_open(store, whitespace_analyzer_new(false), NULL);
    for (i = 0; i < FILTER_DOCS_SIZE; i++) {
        Document *doc = doc_new();
        doc->boost = (float)(i+1);
        doc_add_field(doc, df_add_data(df_new(num), data[i].num));
        doc_add_field(doc, df_add_data(df_new(date), data[i].date));
        doc_add_field(doc, df_add_data(df_new(flipflop), data[i].flipflop));
        iw_add_doc(iw, doc);
        doc_destroy(doc);
    }
    iw_close(iw);
    return;
}
Example #5
0
static Document *prep_doc()
{
    Document *doc = doc_new();
    doc_add_field(
        doc,
        df_add_data(
            df_new(I("content")),
            estrdup("http://_____________________________________________________")
            )
        )->destroy_data = true;
    return doc;

}