This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Depending on your platform and your JVM, this method will pick the | |
// fastest LZ4Factory instance available | |
LZ4Factory factory = LZ4Factory.fastestInstance(); | |
byte[] data = "12345345234572".getBytes("UTF-8"); | |
final int decompressedLength = data.length; | |
// compress data | |
LZ4Compressor compressor = factory.fastCompressor(); | |
// or factory.highCompressor() for slower compression but better compression ratio |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
XXHashFactory factory = XXHashFactory.fastestInstance(); | |
byte[] data = "12345345234572".getBytes("UTF-8"); | |
XXHash32 hash32 = factory.hash32(); | |
int seed = 0x9747b28c; // used to initialize the hash value, use whatever | |
// value you want, but always the same | |
int hash = hash32.hash(data, 0, data.length, seed); | |
System.out.println("Block hash: " + hash); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
XXHashFactory factory = XXHashFactory.fastestInstance(); | |
byte[] data = "12345345234572".getBytes("UTF-8"); | |
ByteArrayInputStream in = new ByteArrayInputStream(data); | |
int seed = 0x9747b28c; // used to initialize the hash value, use whatever | |
// value you want, but always the same | |
StreamingXXHash32 hash32 = factory.newStreamingHash32(seed); | |
byte[] buf = new byte[8]; // for real-world usage, use a larger buffer, like 8192 bytes | |
for (;;) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Both arrays must have the same length | |
// scores[i] is the score of objects[i] | |
final Object[] objects = ...; | |
final float[] scores = ...; | |
new IntroSorter() { | |
float pivotScore; | |
@Override |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"settings": { | |
"analysis": { | |
"analyzer": { | |
"french2": { | |
"type": "custom", | |
"tokenizer": "standard", | |
"filter": ["standard","asciifolding","elision","lowercase","stop_fr","light_french_stem"] | |
} | |
}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Set codec, dir and segmentName accordingly to the segment you are trying to restore | |
Codec codec = new Lucene42Codec(); | |
Directory dir = FSDirectory.open(new File("/tmp/test")); | |
String segmentName = "_0"; | |
IOContext ioContext = new IOContext(); | |
SegmentInfo segmentInfos = codec.segmentInfoFormat().getSegmentInfoReader().read(dir, segmentName, ioContext); | |
Directory segmentDir; | |
if (segmentInfos.getUseCompoundFile()) { | |
segmentDir = new CompoundFileDirectory(dir, IndexFileNames.segmentFileName(segmentName, "", IndexFileNames.COMPOUND_FILE_EXTENSION), ioContext, false); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -XDELETE localhost:9200/test?pretty | |
echo | |
curl -XPUT localhost:9200/test?pretty -d '{ | |
"settings": { | |
"analysis" : { | |
"analyzer" : { | |
"str_search_analyzer" : { | |
"tokenizer" : "whitespace", | |
"filter" : ["lowercase"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Licensed to ElasticSearch and Shay Banon under one | |
* or more contributor license agreements. See the NOTICE file | |
* distributed with this work for additional information | |
* regarding copyright ownership. ElasticSearch licenses this | |
* file to you under the Apache License, Version 2.0 (the | |
* "License"); you may not use this file except in compliance | |
* with the License. You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -XDELETE 'localhost:9200/test?pretty' | |
echo | |
curl -XPUT 'localhost:9200/test?pretty' -d ' | |
{ | |
"settings" : { | |
"index" : { | |
"analysis" : { | |
"analyzer" : { | |
"default" : { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
curl -XGET "http://localhost:9200/movies/_search" -d' | |
{ | |
"query": { | |
"nested": { | |
"path": "credits", | |
"query": { | |
"match": { | |
"credits.person_id": 1 | |
} | |
} |
OlderNewer