Skip to content

Commit

Permalink
DOC: Fix README.md & docs to comply with v2
Browse files Browse the repository at this point in the history
  • Loading branch information
sdqri committed Aug 21, 2024
1 parent 082fd39 commit e66b1cd
Show file tree
Hide file tree
Showing 44 changed files with 2,140 additions and 475 deletions.
16 changes: 11 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ This module provides a simple and functional way to build Elasticsearch queries
- **Procedural query creation:** ✨ Designed for straightforward and refined query building, particularly useful when queries need to be generated programmatically.
- **Comprehensive query support:** 📚 Covers most compound, full-text, and term-level queries, with easy extension for additional types.

For more information, detailed guides, and examples, please read the [documentation](https://sdqri.github.com/effdsl).
For more information, detailed guides, and examples, please read the [documentation](https://sdqri.github.io/effdsl).

## Getting started

Expand All @@ -33,7 +33,7 @@ to your code, and then `go [build|run|test]` will automatically fetch the necess
Otherwise, run the following Go command to install the `effdsl` package:

```sh
$ go get -u github.com/sdqri/effdsl
$ go get -u github.com/sdqri/effdsl/v2
```

### How to use
Expand Down Expand Up @@ -73,17 +73,23 @@ And here’s the same query using effdsl:
```go
import (
es "github.com/elastic/go-elasticsearch/v8"
mq "github.com/sdqri/effdsl/queries/matchquery"

"github.com/sdqri/effdsl"
mq "github.com/sdqri/effdsl/queries/matchquery"
)

query, err := effdsl.Define(mq.MatchQuery("message", "Hello World"))
query, err := effdsl.Define(
effdsl.WithQuery(
mq.MatchQuery("message", "Hello World"),
),
)

res, err := es.Search(
es.Search.WithBody(strings.NewReader(query)),
)
```

For more examples and details on query parameters, visit the [documentation](https://sdqri.github.com/effdsl).
For more examples and details on query parameters, visit the [documentation](https://sdqri.github.io/effdsl).

## 🤝 Contribution
Contributions are welcome! Whether it's fixing a bug 🐛, adding a new feature 🌟, or improving the documentation 📚, your help is appreciated. Please check out the CONTRIBUTING.md guide to get started.
Expand Down
27 changes: 16 additions & 11 deletions docs-src/docs/bool_query.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,26 @@ The bool query adopts a more-matches-is-better approach, so the score from each

```go
import (
"github.com/sdqri/effdsl"
es "github.com/elastic/go-elasticsearch/v8"
mq "github.com/sdqri/effdsl/queries/matchquery"
bq "github.com/sdqri/effdsl/queries/boolquery"

"github.com/sdqri/effdsl/v2"
mq "github.com/sdqri/effdsl/v2/queries/matchquery"
bq "github.com/sdqri/effdsl/v2/queries/boolquery"
)

query, err := effdsl.Define(
bq.Must(mq.MatchQuery(effdsl.M{"user.name": "john_doe"})),
bq.Must(mq.MatchQuery("post.status": "published")),
bq.Filter(mq.MatchQuery("category": "technology")),
bq.Filter(mq.MatchQuery("tags": "go")),
bq.Should(mq.MatchQuery("title": "elasticsearch")),
bq.Should(mq.MatchQuery("content": "search optimization")),
bq.MustNot(mq.MatchQuery("user.role": "banned")),
bq.MustNot(mq.MatchQuery("status": "draft")),
effdsl.WithQuery(
bq.BoolQuery(
bq.Must(mq.MatchQuery(effdsl.M{"user.name": "john_doe"})),
bq.Must(mq.MatchQuery("post.status": "published")),
bq.Filter(mq.MatchQuery("category": "technology")),
bq.Filter(mq.MatchQuery("tags": "go")),
bq.Should(mq.MatchQuery("title": "elasticsearch")),
bq.Should(mq.MatchQuery("content": "search optimization")),
bq.MustNot(mq.MatchQuery("user.role": "banned")),
bq.MustNot(mq.MatchQuery("status": "draft")),
),
),
)

res, err := es.Search(
Expand Down
19 changes: 12 additions & 7 deletions docs-src/docs/boosting_query.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,21 @@ A boosting query matches documents based on a positive query while reducing the

```go
import (
"github.com/sdqri/effdsl"
bq "github.com/sdqri/effdsl/queries/boostingquery"
tq "github.com/sdqri/effdsl/queries/termquery"
es "github.com/elastic/go-elasticsearch/v8"

"github.com/sdqri/effdsl/v2"
bq "github.com/sdqri/effdsl/v2/queries/boostingquery"
tq "github.com/sdqri/effdsl/v2/queries/termquery"
)

query, err := effdsl.Define(
bq.BoostingQuery(
tq.TermQuery("text", "apple"),
tq.TermQuery("text", "pie tart fruit crumble tree"),
0.5,
effdsl.WithQuery(
bq.BoostingQuery(
tq.TermQuery("text", "apple"),
tq.TermQuery("text", "pie tart fruit crumble tree"),
0.5,
),
),
)

res, err := es.Search(
Expand Down
18 changes: 11 additions & 7 deletions docs-src/docs/constant_score.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,20 @@ A constant score query wraps a filter query and returns every matching document

```go
import (
"github.com/sdqri/effdsl"
csq "github.com/sdqri/effdsl/queries/constantscore"
tq "github.com/sdqri/effdsl/queries/termquery"
es "github.com/elastic/go-elasticsearch/v8"

"github.com/sdqri/effdsl/v2"
csq "github.com/sdqri/effdsl/v2/queries/constantscore"
tq "github.com/sdqri/effdsl/v2/queries/termquery"
)

query, err := effdsl.Define(
csq.ConstantScoreQuery(
tq.TermQuery("user.id", "kimchy"),
1.2
)
effdsl.WithQuery(
csq.ConstantScoreQuery(
tq.TermQuery("user.id", "kimchy"),
1.2
),
),
)

res, err := es.Search(
Expand Down
24 changes: 14 additions & 10 deletions docs-src/docs/dis_max_query.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,23 @@ A disjunction max query (dis_max) is used to find documents that match multiple

```go
import (
"github.com/sdqri/effdsl"
dmq "github.com/sdqri/effdsl/queries/dismaxquery"
tq "github.com/sdqri/effdsl/queries/termquery"
es "github.com/elastic/go-elasticsearch/v8"

"github.com/sdqri/effdsl/v2"
dmq "github.com/sdqri/effdsl/v2/queries/dismaxquery"
tq "github.com/sdqri/effdsl/v2/queries/termquery"
)

query, err := effdsl.Define(
dmq.DisMaxQuery(
[]effdsl.QueryResult{
tq.TermQuery("title", "Quick pets"),
tq.TermQuery("body", "Quick pets"),
},
dmq.WithTieBreaker(0.7),
)
effdsl.WithQuery(
dmq.DisMaxQuery(
[]effdsl.QueryResult{
tq.TermQuery("title", "Quick pets"),
tq.TermQuery("body", "Quick pets"),
},
dmq.WithTieBreaker(0.7),
),
),
)

res, err := es.Search(
Expand Down
10 changes: 7 additions & 3 deletions docs-src/docs/exists_query.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@ An exists query returns documents that contain an indexed value for a specified

```go
import (
"github.com/sdqri/effdsl"
eq "github.com/sdqri/effdsl/queries/existsquery"
es "github.com/elastic/go-elasticsearch/v8"

"github.com/sdqri/effdsl/v2"
eq "github.com/sdqri/effdsl/v2/queries/existsquery"
)

query, err := effdsl.Define(
eq.ExistsQuery("field_name"),
effdsl.WithQuery(
eq.ExistsQuery("field_name"),
),
)

res, err := es.Search(
Expand Down
16 changes: 10 additions & 6 deletions docs-src/docs/fuzzy_query.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,19 @@ To find similar terms, the fuzzy query creates a set of all possible variations,

```go
import (
"github.com/sdqri/effdsl"
eq "github.com/sdqri/effdsl/queries/existsquery"
es "github.com/elastic/go-elasticsearch/v8"

"github.com/sdqri/effdsl/v2"
eq "github.com/sdqri/effdsl/v2/queries/existsquery"
)

query, err := effdsl.Define(
fq.FuzzyQuery(
"user.id",
"ki",
)
effdsl.WithQuery(
fq.FuzzyQuery(
"user.id",
"ki",
),
),
)

res, err := es.Search(
Expand Down
10 changes: 7 additions & 3 deletions docs-src/docs/ids_query.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@ Returns documents based on their IDs.

```go
import (
"github.com/sdqri/effdsl"
iq "github.com/sdqri/effdsl/queries/idsquery"
es "github.com/elastic/go-elasticsearch/v8"

"github.com/sdqri/effdsl/v2"
iq "github.com/sdqri/effdsl/v2/queries/idsquery"
)

query, err := effdsl.Define(
iq.IDsQuery("1", "4", "100"),
effdsl.WithQuery(
iq.IDsQuery("1", "4", "100"),
),
)

res, err := es.Search(
Expand Down
14 changes: 10 additions & 4 deletions docs-src/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ to your code, and then `go [build|run|test]` will automatically fetch the necess
Otherwise, run the following Go command to install the `effdsl` package:

```sh
$ go get -u github.com/sdqri/effdsl
$ go get -u github.com/sdqri/effdsl/v2
```

### How to use
Expand Down Expand Up @@ -69,17 +69,23 @@ And here’s the same query using effdsl:
```go
import (
es "github.com/elastic/go-elasticsearch/v8"
mq "github.com/sdqri/effdsl/queries/matchquery"

"github.com/sdqri/effdsl"
mq "github.com/sdqri/effdsl/queries/matchquery"
)

query, err := effdsl.Define(mq.MatchQuery("message", "Hello World"))
query, err := effdsl.Define(
effdsl.WithQuery(
mq.MatchQuery("message", "Hello World"),
),
)

res, err := es.Search(
es.Search.WithBody(strings.NewReader(query)),
)
```

For more examples and details on query parameters, visit the [documentation](https://sdqri.github.com/effdsl).
For more examples and details on query parameters, visit the [documentation](https://sdqri.github.io/effdsl).

## 🤝 Contribution
Contributions are welcome! Whether it's fixing a bug 🐛, adding a new feature 🌟, or improving the documentation 📚, your help is appreciated. Please check out the CONTRIBUTING.md guide to get started.
Expand Down
18 changes: 11 additions & 7 deletions docs-src/docs/match_bool_prefix.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,20 @@ A match bool prefix query analyzes its input and constructs a bool query from th

```go
import (
"github.com/sdqri/effdsl"
mbpq "github.com/sdqri/effdsl/queries/matchboolprefix"
es "github.com/elastic/go-elasticsearch/v8"

"github.com/sdqri/effdsl/v2"
mbpq "github.com/sdqri/effdsl/v2/queries/matchboolprefix"
)

query, err := effdsl.Define(
mbpq.MatchBoolPrefixQuery(
"message",
"quick brown f",
mbpq.WithAnalyzer("keyword"),
)
effdsl.WithQuery(
mbpq.MatchBoolPrefixQuery(
"message",
"quick brown f",
mbpq.WithAnalyzer("keyword"),
),
),
)

res, err := es.Search(
Expand Down
22 changes: 13 additions & 9 deletions docs-src/docs/match_phrase_prefix.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,22 @@ A match phrase prefix query returns documents that match a given phrase with a p

```go
import (
"github.com/sdqri/effdsl"
mppq "github.com/sdqri/effdsl/queries/matchphraseprefixquery"
es "github.com/elastic/go-elasticsearch/v8"

"github.com/sdqri/effdsl/v2"
mppq "github.com/sdqri/effdsl/v2/queries/matchphraseprefixquery"
)

query, err := effdsl.Define(
mppq.MatchPhrasePrefixQuery(
"field_name",
"some phrase prefix query",
mppq.WithAnalyzer("my_analyzer"),
mppq.WithSlop(2),
mppq.WithMaxExpansions(10),
)
effdsl.WithQuery(
mppq.MatchPhrasePrefixQuery(
"field_name",
"some phrase prefix query",
mppq.WithAnalyzer("my_analyzer"),
mppq.WithSlop(2),
mppq.WithMaxExpansions(10),
),
),
)

res, err := es.Search(
Expand Down
Loading

0 comments on commit e66b1cd

Please sign in to comment.