Skip to content

Instantly share code, notes, and snippets.

@naoa
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save naoa/f9b83dfb67f6cb077d27 to your computer and use it in GitHub Desktop.
Save naoa/f9b83dfb67f6cb077d27 to your computer and use it in GitHub Desktop.

オンラインインデックス構築

table_create Documents TABLE_HASH_KEY ShortText
[[0,0.0,0.0],true]
column_create Documents content COLUMN_SCALAR Text
[[0,0.0,0.0],true]
table_create Terms TABLE_PAT_KEY|KEY_NORMALIZE ShortText --default_tokenizer TokenBigram
[[0,0.0,0.0],true]
column_create Terms document_index COLUMN_INDEX|WITH_POSITION Documents content
[[0,0.0,0.0],true]
load --table Documents
[
["_key", "content"],
["1", "this is a pen"],
["2", "this is a pen"],
["3", "this is a pen"],
["4", "this is a pen"],
["5", "this is a pen"]
]
[[0,0.0,0.0],5]
select Documents --filter 'content *S "pen"' --output_columns '_key, _score, content'
[
  [
    0,
    0.0,
    0.0
  ],
  [
    [
      [
        5
      ],
      [
        [
          "_key",
          "ShortText"
        ],
        [
          "_score",
          "Int32"
        ],
        [
          "content",
          "Text"
        ]
      ],
      [
        "1",
        104858,
        "this is a pen"
      ],
      [
        "2",
        104858,
        "this is a pen"
      ],
      [
        "3",
        104858,
        "this is a pen"
      ],
      [
        "4",
        104858,
        "this is a pen"
      ],
      [
        "5",
        104858,
        "this is a pen"
      ]
    ]
  ]
]
select Terms
[
  [
    0,
    0.0,
    0.0
  ],
  [
    [
      [
        4
      ],
      [
        [
          "_id",
          "UInt32"
        ],
        [
          "_key",
          "ShortText"
        ],
        [
          "document_index",
          "Documents"
        ]
      ],
      [
        3,
        "a",
        9
      ],
      [
        2,
        "is",
        8
      ],
      [
        4,
        "pen",
        10
      ],
      [
        1,
        "this",
        7
      ]
    ]
  ]
]

オフラインインデックス構築

table_create Documents TABLE_HASH_KEY ShortText
[[0,0.0,0.0],true]
column_create Documents content COLUMN_SCALAR Text
[[0,0.0,0.0],true]
table_create Terms TABLE_PAT_KEY|KEY_NORMALIZE ShortText --default_tokenizer TokenBigram
[[0,0.0,0.0],true]
load --table Documents
[
["_key", "content"],
["1", "this is a pen"],
["2", "this is a pen"],
["3", "this is a pen"],
["4", "this is a pen"],
["5", "this is a pen"]
]
[[0,0.0,0.0],5]
column_create Terms document_index COLUMN_INDEX|WITH_POSITION Documents content
[[0,0.0,0.0],true]
select Documents --filter 'content *S "pen"' --output_columns '_key, _score, content'
[
  [
    0,
    0.0,
    0.0
  ],
  [
    [
      [
        5
      ],
      [
        [
          "_key",
          "ShortText"
        ],
        [
          "_score",
          "Int32"
        ],
        [
          "content",
          "Text"
        ]
      ],
      [
        "1",
        524289,
        "this is a pen"
      ],
      [
        "2",
        524289,
        "this is a pen"
      ],
      [
        "3",
        524289,
        "this is a pen"
      ],
      [
        "4",
        524289,
        "this is a pen"
      ],
      [
        "5",
        524289,
        "this is a pen"
      ]
    ]
  ]
]
select Terms
[
  [
    0,
    0.0,
    0.0
  ],
  [
    [
      [
        4
      ],
      [
        [
          "_id",
          "UInt32"
        ],
        [
          "_key",
          "ShortText"
        ],
        [
          "document_index",
          "Documents"
        ]
      ],
      [
        1,
        "a",
        2
      ],
      [
        2,
        "is",
        2
      ],
      [
        3,
        "pen",
        2
      ],
      [
        4,
        "this",
        2
      ]
    ]
  ]
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment