X-Git-Url: http://git.indexdata.com/?p=idzebra-moved-to-github.git;a=blobdiff_plain;f=test%2Fapi%2Ft5.c;h=0379cb59fc93f8ddea0d59fd792d6d33a9d178b2;hp=8f568786461bdbc4885f64e40bdfffbda33e9dfc;hb=1922579d92e1a9559d4c3ab4f1cf461f56c83c3b;hpb=bb5e455404dc9d18e846a5508588cf402249a1f9 diff --git a/test/api/t5.c b/test/api/t5.c index 8f56878..0379cb5 100644 --- a/test/api/t5.c +++ b/test/api/t5.c @@ -1,8 +1,5 @@ -/* $Id: t5.c,v 1.22 2007-05-14 13:21:32 adam Exp $ - Copyright (C) 1995-2007 - Index Data ApS - -This file is part of the Zebra server. +/* This file is part of the Zebra server. + Copyright (C) 1995-2008 Index Data Zebra is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -20,7 +17,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -/** t5.c: proximity searches */ +/** \file + \brief test various search attributes */ #include #include "testlib.h" @@ -40,10 +38,19 @@ static void tst(int argc, char **argv) /* simple term */ YAZ_CHECK(tl_query(zh, "@attr 1=4 notfound", 0)); YAZ_CHECK(tl_query(zh, "@attr 1=4 title", 3)); + tl_fetch_compare(zh, 1, "zebra::facet::title:w", yaz_oid_recsyn_sutrs, + "term 3 3: my\n" + "term 3 3: title\n" + "term 2 2: x\n"); /* trunc right */ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=1 titl", 3)); + YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=1 x", 2)); + tl_fetch_compare(zh, 1, "zebra::facet::title:w", yaz_oid_recsyn_sutrs, + "term 2 2: my\n" + "term 2 2: title\n" + "term 2 2: x\n"); /* trunc left */ YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 5=2 titl", 0)); @@ -125,7 +132,11 @@ static void tst(int argc, char **argv) YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 2=5 tu", 2)); YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 2=5 title", 2)); - + /* always-matches relation */ + YAZ_CHECK(tl_query(zh, "@attr 1=_ALLRECORDS @attr 2=103 {ym}", 3)); + YAZ_CHECK(tl_query(zh, "@attr 1=4 @attr 2=103 {x my}", 3)); + YAZ_CHECK(tl_query_x(zh, "@attr 1=1 @attr 2=103 {x my}", 0, 114)); + /* and searches */ YAZ_CHECK(tl_query(zh, "@and @attr 1=4 notfound @attr 1=4 x", 0)); YAZ_CHECK(tl_query(zh, "@and @attr 1=4 x @attr 1=4 notfound", 0)); @@ -189,6 +200,18 @@ static void tst(int argc, char **argv) /* exl=1 distance=2 order=0 relation=3 (=), known, unit=word */ YAZ_CHECK(tl_query(zh, "@attr 1=4 @prox 1 2 1 3 k 2 my x", 1)); + /* Non-indexed numeric use, but specified in bib1.att (bug #1142) */ + YAZ_CHECK(tl_query_x(zh, "@attr 1=1000 x", 0, 114)); + YAZ_CHECK(tl_query_x(zh, "@attr 1=1000 @attr 14=0 x", 0, 114)); + YAZ_CHECK(tl_query_x(zh, "@attr 1=1000 @attr 14=1 x", 0, 0)); + /* Non-indexed numeric use and unspecified in bib1.att */ + YAZ_CHECK(tl_query_x(zh, "@attr 1=999 x", 0, 114)); + YAZ_CHECK(tl_query_x(zh, "@attr 1=999 @attr 14=1 x", 0, 114)); + /* Non-indexed string use attribute */ + YAZ_CHECK(tl_query_x(zh, "@attr 1=gyf x", 0, 114)); + YAZ_CHECK(tl_query_x(zh, "@attr 1=gyf @attr 14=0 x", 0, 114)); + YAZ_CHECK(tl_query_x(zh, "@attr 1=gyf @attr 14=1 x", 0, 0)); + /* provoke unsupported use attribute */ YAZ_CHECK(tl_query_x(zh, "@attr 1=999 @attr 4=1 x", 0, 114)); YAZ_CHECK(tl_query_x(zh, "@attr 1=999 @attr 4=6 x", 0, 114)); @@ -208,7 +231,28 @@ static void tst(int argc, char **argv) /* provoke unsupported relation */ YAZ_CHECK(tl_query_x(zh, "@attr 1=4 @attr 2=6 x", 0, 117)); YAZ_CHECK(tl_query_x(zh, "@attr 1=1016 @attr 2=6 @attr 4=109 x", 0, 114)); - + + /* position , phrase searches */ + YAZ_CHECK(tl_query(zh, "@attr 3=1 title", 0)); + YAZ_CHECK(tl_query(zh, "@attr 3=1 my", 3)); + + YAZ_CHECK(tl_query(zh, "@attr 3=1 {my title}", 2)); + YAZ_CHECK(tl_query(zh, "@attr 4=1 @attr 3=1 {my title}", 2)); + + YAZ_CHECK(tl_query(zh, "@attr 3=1 {title my}", 0)); + YAZ_CHECK(tl_query(zh, "@attr 4=1 @attr 3=1 {title my}", 0)); + + YAZ_CHECK(tl_query(zh, "@attr 4=1 @attr 3=1 {title my}", 0)); + + /* position , or-list */ + YAZ_CHECK(tl_query(zh, "@attr 4=105 @attr 3=1 {title my}", 3)); + YAZ_CHECK(tl_query(zh, "@attr 4=105 @attr 3=1 {title x}", 0)); + + /* position, and-list */ + YAZ_CHECK(tl_query(zh, "@attr 4=6 @attr 3=1 {title my}", 0)); + YAZ_CHECK(tl_query(zh, "@attr 4=6 @attr 3=1 {title x}", 0)); + YAZ_CHECK(tl_query(zh, "@attr 4=6 @attr 3=1 my", 3)); + YAZ_CHECK(tl_close_down(zh, zs)); }