Skip to content

Commit

Permalink
docs: adds community rewards (#371)
Browse files Browse the repository at this point in the history
  • Loading branch information
micheleriva authored May 8, 2023
1 parent 45e899f commit 9df054b
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 141 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const db = await create({
})
```

If you are using Node.js without ESM, please see [build](#builds) section below on how to properly require Orama.
If you are using Node.js without ESM, please see the [usage with CommonJS](#usage-with-commonjs) section below on how to properly require Orama.

Orama will only index string properties, but will allow you to set and store
additional data if needed.
Expand Down Expand Up @@ -194,7 +194,7 @@ Result:
}
```

# Using with CommonJS
# Usage with CommonJS

Orama is packaged as ES modules, suitable for Node.js, Deno, Bun and modern browsers.

Expand Down
8 changes: 7 additions & 1 deletion packages/docs/pages/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Orama is an **immutable, runtime-agnostic, edge, and in-memory full-text search

Through implementing an optimized prefix tree and some clever tweaks, Orama can perform searches through millions of entries in **microseconds**.

Get started in just a few lines of code:
Get started with just a few lines of code:

<Cards>
<Card
Expand Down Expand Up @@ -98,3 +98,9 @@ When importing types, always refer to the standard orama import:
```ts copy
import type { Language } from '@orama/orama'
```
# Community Rewards
![Orama Community Rewards](/misc/community-rewards.png)
Are you using Orama in production? Have you written an article or made a YouTube video on Orama? [Contact us](mailto:info@oramasearch.com) to get some Orama swag in return!
Binary file added packages/docs/public/misc/community-rewards.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
203 changes: 65 additions & 138 deletions packages/orama/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@ Search, everywhere.

# Join Orama's Slack channel

If you need more info, help, or want to provide general feedback on Orama, join
the
[Orama Slack channel](https://join.slack.com/t/orama-community/shared_invite/zt-1gzvj0mmt-yJhJ6pnrSGuwqPmPx9uO5Q)
If you need more info, help, or want to provide general feedback on Orama, join the [Orama Slack channel](https://join.slack.com/t/orama-community/shared_invite/zt-1gzvj0mmt-yJhJ6pnrSGuwqPmPx9uO5Q)

# Highlighted features
- [Search filters](https://docs.oramasearch.com/usage/search/filters)
- [Facets](https://docs.oramasearch.com/usage/search/facets)
- [Fields Boosting](https://docs.oramasearch.com/usage/search/fields-boosting)
- [Typo tolerance](https://docs.oramasearch.com/usage/search/introduction#typo-tolerance)
- [Exact match](https://docs.oramasearch.com/usage/search/introduction#exact-match)
- [Stemming and tokenization in 26 languages](https://docs.oramasearch.com/text-analysis/stemming)

# Installation

Expand Down Expand Up @@ -40,7 +46,7 @@ Or import it directly in a browser module:
</html>
```

Read the complete documentation at [https://docs.oramasearch.com/](https://docs.oramasearch.com/).
Read the complete documentation at [https://docs.oramasearch.com](https://docs.oramasearch.com).

# Usage

Expand All @@ -52,13 +58,17 @@ import { create, insert, remove, search } from '@orama/orama'

const db = await create({
schema: {
author: 'string',
quote: 'string',
name: 'string',
description: 'string',
price: 'number',
meta: {
rating: 'number'
}
},
})
```

If you are using Node.js without ESM, please see [build](#builds) section below on how to properly require Orama.
If you are using Node.js without ESM, please see the [usage with CommonJS](#usage-with-commonjs) section below on how to properly require Orama.

Orama will only index string properties, but will allow you to set and store
additional data if needed.
Expand All @@ -67,75 +77,74 @@ Once the db instance is created, you can start adding some documents:

```js
await insert(db, {
quote: 'It is during our darkest moments that we must focus to see the light.',
author: 'Aristotle',
})

await insert(db, {
quote: 'If you really look closely, most overnight successes took a long time.',
author: 'Steve Jobs',
name: 'Wireless Headphones',
description: 'Experience immersive sound quality with these noise-cancelling wireless headphones.',
price: 99.99,
meta: {
rating: 4.5
}
})

await insert(db, {
quote: 'If you are not willing to risk the usual, you will have to settle for the ordinary.',
author: 'Jim Rohn',
name: 'Smart LED Bulb',
description: 'Control the lighting in your home with this energy-efficient smart LED bulb, compatible with most smart home systems.',
price: 24.99,
meta: {
rating: 4.3
}
})

await insert(db, {
quote: "You miss 100% of the shots you don't take",
author: 'Wayne Gretzky - Michael Scott',
name: 'Portable Charger',
description: 'Never run out of power on-the-go with this compact and fast-charging portable charger for your devices.',
price: 29.99,
meta: {
rating: 3.6
}
})
```

After the data has been inserted, you can finally start to query the database.

```js
const searchResult = await search(db, {
term: 'if',
properties: '*',
boost: {
author: 1.5, // optional: boost author field by x1.5
},
term: 'headphones',
})
```

In the case above, you will be searching for all the documents containing the
word `if`, looking up in every schema property (AKA index):
word `headphones`, looking up in every schema property (AKA index):

```js
{
elapsed: {
raw: 184541,
formatted: '184μs',
raw: 99512,
formatted: '99μs',
},
hits: [
{
id: '41013877-56',
score: 0.025085832971998432,
document: {
quote: 'If you really look closely, most overnight successes took a long time.',
author: 'Steve Jobs'
}
},
{
id: '41013877-107',
score: 0.02315615351261394,
score: 0.925085832971998432,
document: {
quote: 'If you are not willing to risk the usual, you will have to settle for the ordinary.',
author: 'Jim Rohn'
name: 'Wireless Headphones',
description: 'Experience immersive sound quality with these noise-cancelling wireless headphones.',
price: 99.99,
meta: {
rating: 4.5
}
}
}
],
count: 2
count: 1
}
```

You can also restrict the lookup to a specific property:

```js
const searchResult = await search(db, {
term: 'Michael',
properties: ['author'],
term: 'immersive sound quality',
properties: ['description'],
})
```

Expand All @@ -144,30 +153,28 @@ Result:
```js
{
elapsed: {
raw: 172166,
formatted: '172μs',
raw: 21492,
formatted: '21μs',
},
hits: [
{
id: '41045799-144',
score: 0.12041199826559248,
id: '41013877-56',
score: 0.925085832971998432,
document: {
quote: "You miss 100% of the shots you don't take",
author: 'Wayne Gretzky - Michael Scott'
name: 'Wireless Headphones',
description: 'Experience immersive sound quality with these noise-cancelling wireless headphones.',
price: 99.99,
meta: {
rating: 4.5
}
}
}
],
count: 1
}
```

If needed, you can also delete a given document by using the `remove` method:

```js
await remove(db, '41045799-144')
```

### Using with CommonJS
# Usage with CommonJS

Orama is packaged as ES modules, suitable for Node.js, Deno, Bun and modern browsers.

Expand All @@ -189,7 +196,7 @@ async function main() {
main().catch(console.error)
```

#### Use CJS requires
## Use CJS requires

Orama methods can be required as CommonJS modules by requiring from `@orama/orama`.

Expand All @@ -203,95 +210,15 @@ create(/* ... */)
Note that only main methods are supported so for internals and other supported exports you still have to use `await import`.
## Language
Orama supports multiple languages. By default, it will use the `english`
language,
You can specify a different language by using the `language` property
during Orama initialization.
By default, Orama will analyze your input using an English
[Porter Stemmer](https://tartarus.org/martin/PorterStemmer/) function. <br />
You can replace the default stemmer with a custom one, or a pre-built one
shipped with the default Orama installation.
# Community Rewards
Example:
```js
import { create } from '@orama/orama'
import { stemmer } from '@orama/orama/stemmers/it'

const db = await create({
schema: {
author: 'string',
quote: 'string',
},
language: 'italian',
components: {
tokenizer: {
stemmingFn: stemmer,
},
},
})
```
Example using CJS (see [using with commonJS](#using-with-commonjs) above):
```js
async function main() {
const { create } = await import('@orama/orama')
const { stemmer } = await import('@orama/orama/stemmers/it')

const db = await create({
schema: {
author: 'string',
quote: 'string',
},
language: 'italian',
components: {
tokenizer: {
stemmingFn: stemmer,
},
},
})
}

main()
```
![Orama Community Rewards](https://raw.githubusercontent.com/oramasearch/orama/main/misc/readme/community-rewards.png)
Right now, Orama supports 26 languages and stemmers out of the box:
- Arabic
- Armenian
- Bulgarian
- Danish
- Dutch
- English
- Finnish
- French
- German
- Greek
- Hindi
- Hungarian
- Indonesian
- Irish
- Italian
- Nepali
- Norwegian
- Portuguese
- Romanian
- Russian
- Serbian
- Slovenian
- Spanish
- Swedish
- Turkish
- Ukrainian
Are you using Orama in production? Have you written an article or made a YouTube video on Orama? [Contact us](mailto:info@oramasearch.com) to get some Orama swag in return!
# Official Docs
Read the complete documentation at [https://docs.oramasearch.com/](https://docs.oramasearch.com/).
Read the complete documentation at [https://docs.oramasearch.com](https://docs.oramasearch.com).
# License
Expand Down

1 comment on commit 9df054b

@vercel
Copy link

@vercel vercel bot commented on 9df054b May 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.