BloGroonga

2012-09-29

Groonga 2.0.7 has been released

Groonga 2.0.7 has been released!

How to install: Install

There are three topics for this release.

  • Supported to load command by POST
  • Changed package name and port number for server use
  • Supported min and max function

Supported to load command by POST

This release began to support groonga-httpd load command by POST.

Here is the more concrete example.

Schema definition:

  table_create --name Site --flags TABLE_HASH_KEY --key_type ShortText
  column_create --table Site --name title --type ShortText

You can use browser based admin tool by accessing http://localhost:10041/. Create Site table and title column.

After creating Site table and title column, then prepare the POST data as JSON format.

Sample POST data:

  [
  {"_key": "site1", "title":"Web site1 title"}
  ]

Execute curl command to post sample data.

  % curl -X POST 'http://localhost:10041/d/load?table=Site' 
    --verbose -H 'Content-Type: application/json' -d @postbody.txt

You can get following results:

  * About to connect() to localhost port 10041 (#0)
  *   Trying 127.0.0.1... connected
  > POST /d/load?table=Site HTTP/1.1
  > User-Agent: curl/7.22.0 (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
  > Host: localhost:10041
  > Accept: */*
  > Content-Type: application/json
  > Content-Length: 50
  > 
  * upload completely sent off: 50out of 50 bytes
  < HTTP/1.1 200 OK
  < Server: nginx/1.2.1
  < Date: Tue, 25 Sep 2012 05:38:24 GMT
  < Content-Type: application/json
  < Content-Length: 45
  < Connection: keep-alive
  < 
  * Connection #0 to host localhost left intact
  * Closing connection #0
  [[0,1348551504.38352,0.000763893127441406],1]%

Now, you have loaded sample data by POST.

Changed package name and port number for server use

This release began to reconfigure packages for server use.

The groonga project had been provided following packages for server use.

  • groonga-server (HTTP server package)
  • groonga-httpd (HTTP server package)

It is inconvenient for GQTP server use. And there is a problem that port number is conflicted (10041).

Then, we have split groonga-server package into independed one which provides HTTP or GQTP protocol server functionality and reassigned port number for server use.

  • groonga-server-http (HTTP server 10041 port)
  • groonga-server-gqtp (GQTP server 10043 port)
Note: groonga-server-http package and groonga-httpd package are exclusive one.

Supported min and max function

This release began to support min and max function.

  • The min function returns the minimum value within given arguments.
  • The man function returns the maximum value within given arguments.

These function enable you to customize full-text search results when the value of score about search results is unevenly distributed.

Schema definition:

  table_create --name Site --flags TABLE_HASH_KEY --key_type ShortText
  column_create --table Site --name title --type ShortText
  column_create --table Site --name point --type Int8

  table_create --name Terms --flags TABLE_PAT_KEY|KEY_NORMALIZE --key_type ShortText --default_tokenizer TokenBigram
  column_create --table Terms --name blog_title --flags COLUMN_INDEX|WITH_POSITION --type Site --source title

Sample data:

  load --table Site
  [
  {"_key":"http://example.org/","title":"This is test record 1!","point":1},
  {"_key":"http://example.net/","title":"test record 2.","point":2},
  {"_key":"http://example.com/","title":"test test record three.","point":3},
  {"_key":"http://example.net/afr","title":"test record four.", "point":4},
  {"_key":"http://example.org/aba","title":"test test test record five.","point":5},
  {"_key":"http://example.com/rab","title":"test test test test record six.","point":0},
  {"_key":"http://example.net/atv","title":"test test test record seven.","point":7},
  {"_key":"http://example.org/gat","title":"test test record eight.","point":8},
  {"_key":"http://example.com/vdw","title":"test test record nine.","point":9},
  ]

For example, There is a situation that you want to execute full-text search by specified word (test) stored at title column. (There are some data that the value of importance is already stored at point column.)

If you want to get matched and sorted results with specified word (test), here is the query.

  > select --table Site --query title:@test --output_columns _id,_score,title,point  --sortby -_score,-point

  ["_id","UInt32"],["_score","Int32"],["title","ShortText"],["point","Int8"]
  [6,4,"test test test test record six.",0],
  [7,3,"test test test record seven.",7],
  [5,3,"test test test record five.",5],
  [9,2,"test test record nine.",9],
  [8,2,"test test record eight.",8],
  [3,2,"test test record three.",3],
  [4,1,"test record four.",4],
  [2,1,"test record 2.",2],
  [1,1,"This is test record 1!",1]

But, it returns "test test test test record fix." as best matched result.

The min function satisfy the demand that you want to customize the matched results by eliminating unwanted ones.

There is the way to customize the value of _score column by using min function.

  > select --table Site --query title:@test --output_columns _id,_score,title,point 
      --scorer '_score = min(_score, 3) --sortby -_score,-point

  ["_id","UInt32"],["_score","Int32"],["title","ShortText"],["point","Int8"]
  [7,3,"test test test record seven.",7],
  [5,3,"test test test record five.",5],
  [6,3,"test test test test record six.",0],
  [9,2,"test test record nine.",9],
  [8,2,"test test record eight.",8],
  [3,2,"test test record three.",3],
  [4,1,"test record four.",4],
  [2,1,"test record 2.",2],[1,1,"This is test record 1!",1]

Now, you can get the intended results which consider matched results and the value of importance.

Conclusion

See Release 2.0.7 2012/09/29 about detailed changes since 2.0.6.

Let's search by groonga!