Hash functions

**Syntax**

```
wordShingleMinHashCaseInsensitiveUTF8(string[, shinglesize, hashnum])
```

**Arguments**

- `string` — String for which to compute the hash. [`String`](/docs/sql-reference/data-types/string)
- `shinglesize` — Optional. The size of a word shingle, any number from `1` to `25`. The default value is `3`. [`UInt8`](/docs/sql-reference/data-types/int-uint)
- `hashnum` — Optional. The number of minimum and maximum hashes used to calculate the result, any number from `1` to `25`. The default value is `6`. [`UInt8`](/docs/sql-reference/data-types/int-uint)

**Returned value**

Returns a tuple with two hashes — the minimum and the maximum. [`Tuple(UInt64, UInt64)`](/docs/sql-reference/data-types/tuple)

**Examples**

**Usage example**

```
SELECT wordShingleMinHashCaseInsensitiveUTF8('ClickHouse® is a column-oriented database management system (DBMS) for online analytical processing of queries (OLAP).') AS Tuple;
```

```
┌─Tuple─────────────────────────────────────┐
│ (3065874883688416519,1634050779997673240) │
└───────────────────────────────────────────┘
```

## wordShingleMinHashUTF8[​](#wordShingleMinHashUTF8 "Direct link to wordShingleMinHashUTF8")

Introduced in: v21.1.0

Splits a UTF-8 string into parts (shingles) of `shinglesize` words, calculates hash values for each word shingle and returns a tuple with these hashes.
Uses `hashnum` minimum hashes to calculate the minimum hash and `hashnum` maximum hashes to calculate the maximum hash.
It is case sensitive.

Can be used to detect semi-duplicate strings with [`tupleHammingDistance`](/docs/sql-reference/functions/tuple-functions#tupleHammingDistance).
For two strings, if the returned hashes are the same for both strings, then those strings are the same.

**Syntax**

```
wordShingleMinHashUTF8(string[, shinglesize, hashnum])
```

**Arguments**

- `string` — String for which to compute the hash. [`String`](/docs/sql-reference/data-types/string)
- `shinglesize` — Optional. The size of a word shingle, any number from `1` to `25`. The default value is `3`. [`UInt8`](/docs/sql-reference/data-types/int-uint)
- `hashnum` — Optional. The number of minimum and maximum hashes used to calculate the result, any number from `1` to `25`. The default value is `6`. [`UInt8`](/docs/sql-reference/data-types/int-uint)

**Returned value**

Returns a tuple with two hashes — the minimum and the maximum. [`Tuple(UInt64, UInt64)`](/docs/sql-reference/data-types/tuple)

**Examples**

**Usage example**

```
SELECT wordShingleMinHashUTF8('ClickHouse® is a column-oriented database management system (DBMS) for online analytical processing of queries (OLAP).') AS Tuple;
```

```
┌─Tuple──────────────────────────────────────┐
│ (16452112859864147620,5844417301642981317) │
└────────────────────────────────────────────┘
```

## wordShingleSimHash[​](#wordShingleSimHash "Direct link to wordShingleSimHash")

Introduced in: v21.1.0

Splits a ASCII string into parts (shingles) of `shinglesize` words and returns the word shingle `simhash`.
Is is case sensitive.

Can be used for detection of semi-duplicate strings with [`bitHammingDistance`](/docs/sql-reference/functions/bit-functions#bitHammingDistance).
The smaller the [Hamming distance](https://en.wikipedia.org/wiki/Hamming_distance) of the calculated `simhashes` of two strings, the more likely these strings are the same.

**Syntax**

```
wordShingleSimHash(string[, shinglesize])
```

**Arguments**

- `string` — String for which to compute the hash. [`String`](/docs/sql-reference/data-types/string)
- `shinglesize` — Optional. The size of a word shingle, any number from `1` to `25`. The default value is `3`. [`UInt8`](/docs/sql-reference/data-types/int-uint)

**Returned value**

Returns the computed hash value. [`UInt64`](/docs/sql-reference/data-types/int-uint)

**Examples**

**Usage example**

```
SELECT wordShingleSimHash('ClickHouse® is a column-oriented database management system (DBMS) for online analytical processing of queries (OLAP).') AS Hash;
```

```
┌───────Hash─┐
│ 2328277067 │
└────────────┘
```

## wordShingleSimHashCaseInsensitive[​](#wordShingleSimHashCaseInsensitive "Direct link to wordShingleSimHashCaseInsensitive")

Introduced in: v21.1.0

Splits a ASCII string into parts (shingles) of `shinglesize` words and returns the word shingle `simhash`.
It is case insensitive.

Can be used for detection of semi-duplicate strings with [`bitHammingDistance`](/docs/sql-reference/functions/bit-functions#bitHammingDistance).
The smaller the [Hamming distance](https://en.wikipedia.org/wiki/Hamming_distance) of the calculated `simhashes` of two strings, the more likely these strings are the same.

**Syntax**

```
wordShingleSimHashCaseInsensitive(string[, shinglesize])
```

**Arguments**

- `string` — String for which to compute the hash. [`String`](/docs/sql-reference/data-types/string)
- `shinglesize` — Optional. The size of a word shingle, any number from `1` to `25`. The default value is `3`. [`UInt8`](/docs/sql-reference/data-types/int-uint)

**Returned value**

Returns the computed hash value. [`UInt64`](/docs/sql-reference/data-types/int-uint)

**Examples**

**Usage example**

```
SELECT wordShingleSimHashCaseInsensitive('ClickHouse® is a column-oriented database management system (DBMS) for online analytical processing of queries (OLAP).') AS Hash;
```

```
┌───────Hash─┐
│ 2194812424 │
└────────────┘
```

## wordShingleSimHashCaseInsensitiveUTF8[​](#wordShingleSimHashCaseInsensitiveUTF8 "Direct link to wordShingleSimHashCaseInsensitiveUTF8")

Introduced in: v1.1.0

Splits a UTF-8 encoded string into parts (shingles) of `shinglesize` words and returns the word shingle `simhash`.
It is case insensitive.

Can be used for detection of semi-duplicate strings with [`bitHammingDistance`](/docs/sql-reference/functions/bit-functions#bitHammingDistance).
The smaller the [Hamming Distance](https://en.wikipedia.org/wiki/Hamming_distance) of the calculated `simhashes` of two strings, the more likely these strings are the same.

**Syntax**

```
wordShingleSimHashCaseInsensitiveUTF8(string[, shinglesize])
```

**Arguments**

- `string` — String for which to compute the hash. [`String`](/docs/sql-reference/data-types/string)
- `shinglesize` — Optional. The size of a word shingle, any number from `1` to `25`. The default value is `3`. [`UInt8`](/docs/sql-reference/data-types/int-uint)

**Returned value**

Returns the computed hash value. [`UInt64`](/docs/sql-reference/data-types/int-uint)

**Examples**

**Usage example**

```
SELECT wordShingleSimHashCaseInsensitiveUTF8('ClickHouse® is a column-oriented database management system (DBMS) for online analytical processing of queries (OLAP).') AS Hash;
```

```
┌───────Hash─┐
│ 2194812424 │
└────────────┘
```

## wordShingleSimHashUTF8[​](#wordShingleSimHashUTF8 "Direct link to wordShingleSimHashUTF8")

Introduced in: v21.1.0

Splits a UTF-8 string into parts (shingles) of `shinglesize` words and returns the word shingle `simhash`.
It is case sensitive.

Can be used for detection of semi-duplicate strings with [`bitHammingDistance`](/docs/sql-reference/functions/bit-functions#bitHammingDistance).
The smaller the [Hamming distance](https://en.wikipedia.org/wiki/Hamming_distance) of the calculated `simhashes` of two strings, the more likely these strings are the same.

**Syntax**

```
wordShingleSimHashUTF8(string[, shinglesize])
```

**Arguments**

- `string` — String for which to compute the hash. [`String`](/docs/sql-reference/data-types/string)
- `shinglesize` — Optional. The size of a word shingle, any number from `1` to `25`. The default value is `3`. [`UInt8`](/docs/sql-reference/data-types/int-uint)

**Returned value**

Returns the computed hash value. [`UInt64`](/docs/sql-reference/data-types/int-uint)

**Examples**

**Usage example**

```
SELECT wordShingleSimHashUTF8('ClickHouse® is a column-oriented database management system (DBMS) for online analytical processing of queries (OLAP).') AS Hash;
```

```
┌───────Hash─┐
│ 2328277067 │
└────────────┘
```

## wyHash64[​](#wyHash64 "Direct link to wyHash64")

Introduced in: v22.7.0