Navigation Menu

Skip to content

Commit

Permalink
Use format
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Oct 10, 2015
1 parent 8088be0 commit e034cac
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 7 deletions.
51 changes: 47 additions & 4 deletions reference/functions/pgroonga-score.md
Expand Up @@ -5,17 +5,60 @@ layout: en

# `pgroonga.score` function

## Summary

`pgroonga.score` function returns precision as a number. If a record is more precision against searched query, the record has more higher number.

## Syntax

You can use `pgroonga.score` function to get precision as a number. If a record is more precision against searched query, the record has more higher number.

You need to add primary key column into `pgroonga` index to use `pgroonga.score` function. If you don't add primary key column into `pgroonga` index, `pgroonga.score` function always returns `0`.
```text
double precision pgroonga.score(record)
```

`record` is a table name.

Assume that you have the following schema:

```sql
CREATE TABLE score_memos (
id integer PRIMARY KEY,
content text
);

CREATE INDEX pgroonga_score_memos_content_index
ON score_memos
USING pgroonga (id, content);
```

`record` must be `score_memos`:

`pgroonga.score` function always returns `0` when full text search isn't performed by index. In other words, `pgroonga.score` function always returns `0` when full text search is performed by sequential scan.
```sql
SELECT *, pgroonga.score(score_memos)
FROM score_memos
WHERE content %% 'PGroonga';
```

If `pgroonga.score` function returns `0` unexpectedly, confirm the followings:
`pgroonga.score` function return precision as `double precision` type value.

## Usage

You need to add primary key column into `pgroonga` index to use `pgroonga.score` function. If you don't add primary key column into `pgroonga` index, `pgroonga.score` function always returns `0.0`.

`pgroonga.score` function always returns `0.0` when full text search isn't performed by index. In other words, `pgroonga.score` function always returns `0` when full text search is performed by sequential scan.

If `pgroonga.score` function returns `0.0` unexpectedly, confirm the followings:

* Whether the column that is specified as primary key is included in index targets of the PGroonga index or not
* Whether the full text search is performed by index or not

Score is "how many keywords are included" (TF, Term Frequency) for now. Groonga supports customizing how to score. But PGroonga doesn't support yet it for now.

See also [examples in tutorial](../../tutorial/#score).
## Usage

See [examples in tutorial](../../tutorial/#score).

## See also

* [Examples in tutorial](../../tutorial/#score)
18 changes: 15 additions & 3 deletions reference/functions/pgroonga-snippet-html.md
Expand Up @@ -5,10 +5,16 @@ layout: en

# `pgroonga.snippet` function

Here is `pgroonga.snippet_html` signature:
## Summary

`pgroonga.snippet_html` function returns texts around keywords from target text. It's also known as [KWIC](https://en.wikipedia.org/wiki/Key_Word_in_Context) (keyword in context). You can see it in search result on Web search engine.

## Syntax

Here is the syntax of this function:

```text
pgroonga.snippet_html(target, ARRAY[keyword1, keyword2, ...])
text[] pgroonga.snippet_html(target, ARRAY[keyword1, keyword2, ...])
```

`target` is a `text` type value. `pgroonga.snippet_html` extracts keywords with around texts from `target`.
Expand All @@ -21,4 +27,10 @@ Element in the returned array is a text around keyword. The keyword is surround

The maximum size of part of `target` in each element is 200 bytes. It's unit is byte not the number of characters. Each element may be lager than 200 bytes because each element includes `<span class="keyword">` and `</span>` and may have HTML escaped values. If '<' is HTML escaped to `&lt;`, the byte size is increased to 4 from 1.

See also [examples in tutorial](../../tutorial/#snippet).
## Usage

See [examples in tutorial](../../tutorial/#snippet).

## See also

* [Examples in tutorial](../../tutorial/#snippet)

0 comments on commit e034cac

Please sign in to comment.