Browse Source

NOBUG Update using serdewq

develop
Paul Masurel 7 years ago
parent
commit
7dc2f7fd57
8 changed files with 135 additions and 46 deletions
  1. +104
    -20
      Cargo.lock
  2. +6
    -3
      Cargo.toml
  3. +1
    -1
      README.md
  4. +1
    -2
      src/commands/bench.rs
  5. +9
    -9
      src/commands/new.rs
  6. +4
    -4
      src/commands/search.rs
  7. +6
    -6
      src/commands/serve.rs
  8. +4
    -1
      src/main.rs

+ 104
- 20
Cargo.lock View File

@@ -1,6 +1,6 @@
[root]
name = "tantivy-cli"
version = "0.3.0"
version = "0.4.0-alpha"
dependencies = [
"ansi_term 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"bincode 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -13,9 +13,11 @@ dependencies = [
"log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
"mount 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"persistent 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"staticfile 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"tantivy 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"tantivy 0.4.0-alpha",
"time 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)",
"urlencoded 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"version 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -86,13 +88,12 @@ dependencies = [

[[package]]
name = "bincode"
version = "0.5.9"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
"byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 0.7.15 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 0.9.15 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
@@ -208,6 +209,11 @@ name = "dtoa"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "dtoa"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "either"
version = "1.1.0"
@@ -349,6 +355,11 @@ name = "itoa"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "itoa"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "kernel32-sys"
version = "0.2.2"
@@ -577,6 +588,11 @@ dependencies = [
"getopts 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "quote"
version = "0.3.15"
source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "rand"
version = "0.3.15"
@@ -657,13 +673,37 @@ dependencies = [

[[package]]
name = "serde"
version = "0.7.15"
version = "0.8.23"
source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "serde"
version = "0.8.23"
version = "0.9.15"
source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "serde"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "serde_derive"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive_internals 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "serde_derive_internals"
version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)",
"synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "serde_json"
@@ -676,6 +716,17 @@ dependencies = [
"serde 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "serde_json"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"dtoa 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"itoa 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "skeptic"
version = "0.6.1"
@@ -712,12 +763,29 @@ version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "tantivy"
version = "0.3.1"
name = "syn"
version = "0.11.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
"synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "synom"
version = "0.11.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
name = "tantivy"
version = "0.4.0-alpha"
dependencies = [
"atomicwrites 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"bincode 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)",
"bincode 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"bit-set 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"chan 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -735,11 +803,13 @@ dependencies = [
"memmap 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"num_cpus 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
"tempfile 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.36 (registry+https://github.com/rust-lang/crates.io-index)",
"uuid 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"uuid 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"version 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -874,6 +944,11 @@ name = "unicode-width"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "unicode-xid"
version = "0.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "unreachable"
version = "0.1.1"
@@ -922,11 +997,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"

[[package]]
name = "uuid"
version = "0.4.0"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"rand 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
]

[[package]]
@@ -963,7 +1038,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum atomicwrites 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c4328d3fa4af4aedc582587976a0f74decc73f90ea7cae3d757c0535f983d16f"
"checksum atty 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d912da0db7fa85514874458ca3651fe2cddace8d0b0505571dbdcd41ab490159"
"checksum bincode 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "60f89d68caf4f2e8a94efd192a2b8393869e72336dea4e0fe077cc6eb5f2057e"
"checksum bincode 0.5.9 (registry+https://github.com/rust-lang/crates.io-index)" = "aa413a0580cf7d54f1938c13462fd32cff9099338bf161e15870cb05021df745"
"checksum bincode 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bea6e613eeed56804328309c4227e61a0326a8810e1392d91faeb2124b77f43e"
"checksum bit-set 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d9bf6104718e80d7b26a68fdbacff3481cfc05df670821affc7e9cbc1884400c"
"checksum bit-vec 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "5b97c2c8e8bbb4251754f559df8af22fb264853c7d009084a576cdf12565089d"
"checksum bitflags 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8dead7461c1127cf637931a1e50934eb6eee8bff2f74433ac7909e9afcee04a3"
@@ -980,6 +1055,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum cookie 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0e3d6405328b6edb412158b3b7710e2634e23f3614b9bb1c412df7952489a626"
"checksum crossbeam 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "0c5ea215664ca264da8a9d9c3be80d2eaf30923c259d03e870388eb927508f97"
"checksum dtoa 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0dd841b58510c9618291ffa448da2e4e0f699d984d436122372f446dae62263d"
"checksum dtoa 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "80c8b71fd71146990a9742fc06dcbbde19161a267e0ad4e572c35162f4578c90"
"checksum either 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "18785c1ba806c258137c937e44ada9ee7e69a37e3c72077542cd2f069d78562a"
"checksum env_logger 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "15abd780e45b3ea4f76b4e9a26ff4843258dd8a3eed2775a0e7368c2e7936c2f"
"checksum error 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "a6e606f14042bb87cc02ef6a14db6c90ab92ed6f62d87e69377bc759fd7987cc"
@@ -996,6 +1072,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum iron 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9fb1b2d809f84bf347e472d5758762b5c804e0c622970235f156d82673e4d334"
"checksum itertools 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4833d6978da405305126af4ac88569b5d71ff758581ce5a987dbfa3755f694fc"
"checksum itoa 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ae3088ea4baeceb0284ee9eea42f591226e6beaecf65373e41b38d95a1b8e7a1"
"checksum itoa 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "eb2f404fbc66fd9aac13e998248505e7ecb2ad8e44ab6388684c5fb11c6c251c"
"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
"checksum language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a"
"checksum lazy_static 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "cf186d1a8aa5f5bee5fd662bc9c1b949e0259e1bcc379d1f006847b0080c7417"
@@ -1024,6 +1101,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum persistent 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0c0aea7e6e026f9090c56aa7cda9d4ad6f182c717f0640cb03beace1f75a43d2"
"checksum plugin 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "1a6a0dc3910bc8db877ffed8e457763b317cf880df4ae19109b9f77d277cf6e0"
"checksum pulldown-cmark 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8361e81576d2e02643b04950e487ec172b687180da65c731c03cf336784e6c07"
"checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a"
"checksum rand 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "022e0636ec2519ddae48154b028864bdce4eaf7d35226ab8e65c611be97b189d"
"checksum redox_syscall 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "29dbdfd4b9df8ab31dec47c6087b7b13cbf4a776f335e4de8efba8288dda075b"
"checksum regex 0.1.80 (registry+https://github.com/rust-lang/crates.io-index)" = "4fd4ace6a8cf7860714a2c2280d6c1f7e6a413486c13298bbc86fd3da019402f"
@@ -1035,14 +1113,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum semver 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)" = "d4f410fedcf71af0345d7607d246e7ad15faaadd49d240ee3b24e5dc21a820ac"
"checksum sequence_trie 0.0.13 (registry+https://github.com/rust-lang/crates.io-index)" = "d5b4eb0f7d1ff9b9666d8b8ff543f3705dd464025269a5b0e1988ffa60ca1be8"
"checksum serde 0.6.15 (registry+https://github.com/rust-lang/crates.io-index)" = "c97b18e9e53de541f11e497357d6c5eaeb39f0cb9c8734e274abe4935f6991fa"
"checksum serde 0.7.15 (registry+https://github.com/rust-lang/crates.io-index)" = "1b0e0732aa8ec4267f61815a396a942ba3525062e3bd5520aa8419927cfc0a92"
"checksum serde 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)" = "9dad3f759919b92c3068c696c15c3d17238234498bbdcc80f2c469606f948ac8"
"checksum serde 0.9.15 (registry+https://github.com/rust-lang/crates.io-index)" = "34b623917345a631dc9608d5194cc206b3fe6c3554cd1c75b937e55e285254af"
"checksum serde 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3b46a59dd63931010fdb1d88538513f3279090d88b5c22ef4fe8440cfffcc6e3"
"checksum serde_derive 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6c06b68790963518008b8ae0152d48be4bbbe77015d2c717f6282eea1824be9a"
"checksum serde_derive_internals 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "021c338d22c7e30f957a6ab7e388cb6098499dda9fd4ba1661ee074ca7a180d1"
"checksum serde_json 0.8.6 (registry+https://github.com/rust-lang/crates.io-index)" = "67f7d2e9edc3523a9c8ec8cd6ec481b3a27810aafee3e625d311febd3e656b4c"
"checksum serde_json 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "48b04779552e92037212c3615370f6bd57a40ebba7f20e554ff9f55e41a69a7b"
"checksum skeptic 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "34c7f11b6755efa4abfd2739426c17de0a36153510bacd6147113fd3a9f2634d"
"checksum solicit 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "172382bac9424588d7840732b250faeeef88942e37b6e35317dce98cafdd75b2"
"checksum staticfile 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b28e731e7fcc67ce6aa4b53359d6922e193979175fbe85d5558fc71e692e4523"
"checksum strsim 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b4d15c810519a91cf877e7e36e63fe068815c678181439f2f29e2562147c3694"
"checksum tantivy 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "389ee9371eed5bec929bd1384ece956cb1e61764237d94bcab5cf4660faa8be5"
"checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad"
"checksum synom 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6"
"checksum tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "87974a6f5c1dfb344d733055601650059a3363de2a6104819293baff662132d6"
"checksum tempfile 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3213fd2b7ed87e39306737ccfac04b1233b57a33ca64cfbf52f2ffaa2b765e2f"
"checksum term_size 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2b6b55df3198cc93372e85dd2ed817f0e38ce8cc0f22eb32391bfad9c4bf209"
@@ -1060,13 +1143,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
"checksum unicode-normalization 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "e28fa37426fceeb5cf8f41ee273faa7c82c47dc8fba5853402841e665fcd86ff"
"checksum unicode-segmentation 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "18127285758f0e2c6cf325bb3f3d138a12fee27de4f23e146cd6a179f26c2cf3"
"checksum unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "bf3a113775714a22dcb774d8ea3655c53a32debae63a063acc00a91cc586245f"
"checksum unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc"
"checksum unreachable 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1f2ae5ddb18e1c92664717616dd9549dde73f539f01bd7b77c2edb2446bdff91"
"checksum unsafe-any 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b351086021ebc264aea3ab4f94d61d889d98e5e9ec2d985d993f50133537fd3a"
"checksum url 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f5ba8a749fb4479b043733416c244fa9d1d3af3d7c23804944651c8a448cb87e"
"checksum urlencoded 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5ddcf2d3a0beedb5cdf50cabc521ab76a994907877a1d91d996c251d42c70e2e"
"checksum utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a1ca13c08c41c9c3e04224ed9ff80461d97e121589ff27c753a16cb10830ae0f"
"checksum utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "662fab6525a98beff2921d7f61a39e7d59e0b425ebc7d0d9e66d316e55124122"
"checksum uuid 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7cfec50b0842181ba6e713151b72f4ec84a6a7e2c9c8a8a3ffc37bb1cd16b231"
"checksum uuid 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b5d0f5103675a280a926ec2f9b7bcc2ef49367df54e8c570c3311fec919f9a8b"
"checksum vec_map 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f8cdc8b93bd0198ed872357fb2e667f7125646b1762f16d60b2c96350d361897"
"checksum version 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4c941215489baf638156fcc85c59a45444709a7ac2093b9b22b45e3cfe80fe26"
"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"


+ 6
- 3
Cargo.toml View File

@@ -1,6 +1,6 @@
[package]
name = "tantivy-cli"
version = "0.3.0"
version = "0.4.0-alpha"
authors = ["Paul Masurel <paul.masurel@gmail.com>"]

description = """Command line interface for Tantivy, a search engine library."""
@@ -16,7 +16,9 @@ license = "MIT"
time = "0.1"
iron = "0.4"
staticfile = "0.3"
rustc-serialize = "0.3"
serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
persistent="0.2"
clap = "2"
ansi_term = "0.8"
@@ -29,7 +31,8 @@ log = "0.3"
futures = "0.1"
env_logger = "0.3"
version = "2"
tantivy = "0.3.1"
#tantivy = "0.3.1"
tantivy = { path="../tantivy", branch="master" }

[[bin]]
name = "tantivy"


+ 1
- 1
README.md View File

@@ -40,7 +40,7 @@ We will now initialize the index and create its schema.
The [schema](https://tantivy-search.github.io/tantivy/tantivy/schema/index.html) defines
the list of your fields, and for each field:
- its name
- its type, currently `u32` or `str`
- its type, currently `u64`, `i64` or `str`
- how it should be indexed.

You can find more information about the latter on


+ 1
- 2
src/commands/bench.rs View File

@@ -29,8 +29,7 @@ fn extract_search_fields(schema: &Schema) -> Vec<Field> {
.filter(|&(_, field_entry)| {
field_entry.is_indexed()
})
.map(|(field_id, _)| field_id as u8)
.map(Field)
.map(|(field_id, _)| Field(field_id as u32))
.collect()
}



+ 9
- 9
src/commands/new.rs View File

@@ -9,7 +9,7 @@ use ansi_term::Style;
use ansi_term::Colour::{Red, Blue, Green};
use std::io::Write;
use std::ascii::AsciiExt;
use rustc_serialize::json;
use serde_json;


pub fn run_new_cli(matches: &ArgMatches) -> Result<(), String> {
@@ -104,18 +104,18 @@ fn ask_add_field_text(field_name: &str, schema_builder: &mut SchemaBuilder) {
}


fn ask_add_field_u32(field_name: &str, schema_builder: &mut SchemaBuilder) {
let mut u32_options = U32Options::default();
fn ask_add_field_u64(field_name: &str, schema_builder: &mut SchemaBuilder) {
let mut u64_options = IntOptions::default();
if prompt_yn("Should the field be stored") {
u32_options = u32_options.set_stored();
u64_options = u64_options.set_stored();
}
if prompt_yn("Should the field be fast") {
u32_options = u32_options.set_fast();
u64_options = u64_options.set_fast();
}
if prompt_yn("Should the field be indexed") {
u32_options = u32_options.set_indexed();
u64_options = u64_options.set_indexed();
}
schema_builder.add_u32_field(field_name, u32_options);
schema_builder.add_u64_field(field_name, u64_options);
}

fn ask_add_field(schema_builder: &mut SchemaBuilder) {
@@ -126,7 +126,7 @@ fn ask_add_field(schema_builder: &mut SchemaBuilder) {
ask_add_field_text(&field_name, schema_builder);
}
else {
ask_add_field_u32(&field_name, schema_builder);
ask_add_field_u64(&field_name, schema_builder);
}
}

@@ -141,7 +141,7 @@ fn run_new(directory: PathBuf) -> tantivy::Result<()> {
}
}
let schema = schema_builder.build();
let schema_json = format!("{}", json::as_pretty_json(&schema));
let schema_json = format!("{}", serde_json::to_string_pretty(&schema).unwrap());
println!("\n{}\n", Style::new().fg(Green).paint(schema_json));
Index::create(&directory, schema)?;
Ok(())


+ 4
- 4
src/commands/search.rs View File

@@ -1,5 +1,4 @@
use clap::ArgMatches;
use rustc_serialize::json::as_json;
use std::convert::From;
use std::path::Path;
use std::path::PathBuf;
@@ -7,6 +6,7 @@ use tantivy;
use tantivy::Index;
use tantivy::query::QueryParser;
use tantivy::schema::Field;
use serde_json;
use tantivy::schema::FieldType;

pub fn run_search_cli(matches: &ArgMatches) -> Result<(), String> {
@@ -28,11 +28,11 @@ fn run_search(directory: &Path, query: &str) -> tantivy::Result<()> {
FieldType::Str(ref text_field_options) => {
text_field_options.get_indexing_options().is_indexed()
},
FieldType::U32(_) => false
_ => false
}
}
)
.map(|(i, _)| Field(i as u8))
.map(|(i, _)| Field(i as u32))
.collect();
let query_parser = QueryParser::new(schema.clone(), default_fields);
let query = query_parser.parse_query(query)?;
@@ -45,7 +45,7 @@ fn run_search(directory: &Path, query: &str) -> tantivy::Result<()> {
let doc_id = scorer.doc();
let doc = segment_reader.doc(doc_id)?;
let named_doc = schema.to_named_doc(&doc);
println!("{}", as_json(&named_doc));
println!("{}", serde_json::to_string(&named_doc).unwrap());
}
}
Ok(())


+ 6
- 6
src/commands/serve.rs View File

@@ -18,10 +18,10 @@ use clap::ArgMatches;
use iron::mime::Mime;
use iron::prelude::*;
use iron::status;
use serde_json;
use iron::typemap::Key;
use mount::Mount;
use persistent::Read;
use rustc_serialize::json::as_pretty_json;
use std::convert::From;
use std::error::Error;
use std::fmt::{self, Debug};
@@ -51,7 +51,7 @@ pub fn run_serve_cli(matches: &ArgMatches) -> Result<(), String> {
}


#[derive(RustcEncodable)]
#[derive(Serialize)]
struct Serp {
q: String,
num_hits: usize,
@@ -59,7 +59,7 @@ struct Serp {
timings: TimerTree,
}

#[derive(RustcEncodable)]
#[derive(Serialize)]
struct Hit {
doc: NamedFieldDocument,
}
@@ -85,11 +85,11 @@ impl IndexServer {
FieldType::Str(ref text_field_options) => {
text_field_options.get_indexing_options().is_indexed()
},
FieldType::U32(_) => false
_ => false
}
}
)
.map(|(i, _)| Field(i as u8))
.map(|(i, _)| Field(i as u32))
.collect();
let query_parser = QueryParser::new(schema.clone(), default_fields);
IndexServer {
@@ -167,7 +167,7 @@ fn search(req: &mut Request) -> IronResult<Response> {
.get("q")
.ok_or_else(|| IronError::new(StringError(String::from("Parameter q is missing from the query")), status::BadRequest)))[0].clone();
let serp = index_server.search(query, num_hits).unwrap();
let resp_json = as_pretty_json(&serp).indent(4);
let resp_json = serde_json::to_string_pretty(&serp).unwrap();
let content_type = "application/json".parse::<Mime>().unwrap();
Ok(Response::with((content_type, status::Ok, format!("{}", resp_json))))
})


+ 4
- 1
src/main.rs View File

@@ -2,7 +2,7 @@
extern crate clap;
#[macro_use]
extern crate version;
extern crate rustc_serialize;
extern crate serde_json;
#[macro_use]
extern crate log;
extern crate env_logger;
@@ -19,6 +19,9 @@ extern crate mount;
extern crate bincode;
extern crate byteorder;

#[macro_use]
extern crate serde_derive;

use clap::{AppSettings, Arg, App, SubCommand};
mod commands;
use self::commands::*;


Loading…
Cancel
Save