{
int maxlen;
bool rejectlong;
+ bool absval;
} DictInt;
d = (DictInt *) palloc0(sizeof(DictInt));
d->maxlen = 6;
d->rejectlong = false;
+ d->absval = false;
foreach(l, dictoptions)
{
{
d->rejectlong = defGetBoolean(defel);
}
+ else if (strcmp(defel->defname, "absval") == 0)
+ {
+ d->absval = defGetBoolean(defel);
+ }
else
{
ereport(ERROR,
{
DictInt *d = (DictInt *) PG_GETARG_POINTER(0);
char *in = (char *) PG_GETARG_POINTER(1);
- char *txt = pnstrdup(in, PG_GETARG_INT32(2));
+ int len = PG_GETARG_INT32(2);
+ char *txt;
TSLexeme *res = palloc0(sizeof(TSLexeme) * 2);
res[1].lexeme = NULL;
- if (PG_GETARG_INT32(2) > d->maxlen)
+
+ if (d->absval && (in[0] == '+' || in[0] == '-'))
+ {
+ len--;
+ txt = pnstrdup(in + 1, len);
+ }
+ else
+ txt = pnstrdup(in, len);
+
+ if (len > d->maxlen)
{
if (d->rejectlong)
{
ALTER TEXT SEARCH DICTIONARY intdict (MAXLEN = -214783648);
ERROR: maxlen value has to be >= 1
+select ts_lexize('intdict', '-40865854');
+ ts_lexize
+-----------
+ {-40865}
+(1 row)
+
+select ts_lexize('intdict', '+40865854');
+ ts_lexize
+-----------
+ {+40865}
+(1 row)
+
+ALTER TEXT SEARCH DICTIONARY intdict (ABSVAL = true);
+select ts_lexize('intdict', '-40865854');
+ ts_lexize
+-----------
+ {408658}
+(1 row)
+
+select ts_lexize('intdict', '+40865854');
+ ts_lexize
+-----------
+ {408658}
+(1 row)
+
select ts_lexize('intdict', '314532610153');
ALTER TEXT SEARCH DICTIONARY intdict (MAXLEN = -214783648);
+
+select ts_lexize('intdict', '-40865854');
+select ts_lexize('intdict', '+40865854');
+ALTER TEXT SEARCH DICTIONARY intdict (ABSVAL = true);
+select ts_lexize('intdict', '-40865854');
+select ts_lexize('intdict', '+40865854');
<title>Configuration</title>
<para>
- The dictionary accepts two options:
+ The dictionary accepts three options:
</para>
<itemizedlist>
such an integer cannot be searched for.
</para>
</listitem>
+ <listitem>
+ <para>
+ The <literal>absval</literal> parameter specifies whether leading
+ <quote><literal>+</literal></quote> or <quote><literal>-</literal></quote>
+ signs should be removed from integer words. The default
+ is <literal>false</literal>. When <literal>true</literal>, the sign is
+ removed before <literal>maxlen</literal> is applied.
+ </para>
+ </listitem>
</itemizedlist>
</sect2>