Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update docs for search change #177

Merged
merged 1 commit into from
Nov 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 21 additions & 19 deletions 040-SDK/111-search.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The format of a search request at the branch level (across tables) is as follows
<TabbedCode tabs={['TypeScript', 'Python', 'JSON']}>

```ts
const records = await xata.search.all("<search phrase>", {
const results = await xata.search.all("<search phrase>", {
tables: [
{
table: "...",
Expand All @@ -36,7 +36,7 @@ const records = await xata.search.all("<search phrase>", {
```

```python
records = xata.data().search_branch({
results = xata.data().search_branch({
"query": "<search phrase>",
"tables": [{
"table": "...",
Expand Down Expand Up @@ -100,7 +100,7 @@ Which returns results in the following format:
<TabbedCode tabs={['TypeScript', 'Python', 'JSON']}>

```ts
for (const res of results) {
for (const res of results.records) {
// result record
console.log(res.record);
/*
Expand Down Expand Up @@ -139,6 +139,7 @@ for (const res of results) {

```python
{
"totalCount": 1,
"records": [
{
"address": {
Expand All @@ -165,6 +166,7 @@ for (const res of results) {

```json
{
"totalCount": 1,
"records": [
{
"address": {
Expand Down Expand Up @@ -260,7 +262,7 @@ If you want to search in a single table, it's easier to use the table-level sear
<TabbedCode tabs={['TypeScript', 'Python', 'JSON']}>

```ts
const records = await xata.db.Users.search("<search phrase>", {
const results = await xata.db.Users.search("<search phrase>", {
target: [...],
filter: {...},
boosters: [...],
Expand Down Expand Up @@ -393,7 +395,7 @@ The filtering is applied at the table level. For example:

<TabbedCode tabs={['TypeScript', 'Python', 'JSON']}>
```ts
const records = await xata.search.all("new st", {
const results = await xata.search.all("new st", {
tables: [
{
table: "Users",
Expand Down Expand Up @@ -444,7 +446,7 @@ By default, Xata searches across all columns from the selected tables. You can r
<TabbedCode tabs={['TypeScript', 'Python', 'JSON']}>

```ts
const records = await xata.search.all('new st', {
const results = await xata.search.all('new st', {
tables: [
{
table: 'Users',
Expand All @@ -455,7 +457,7 @@ const records = await xata.search.all('new st', {
```

```python
records = xata.data().search_branch({
results = xata.data().search_branch({
"query": "kaanu",
"tables": [
{
Expand Down Expand Up @@ -491,7 +493,7 @@ For example, here we retrieve the second page of up to `10` search results:
<TabbedCode tabs={['TypeScript', 'Python', 'JSON']}>

```ts
const records = await xata.search.all('new st', {
const results = await xata.search.all('new st', {
tables: [
{
table: 'Users',
Expand All @@ -506,7 +508,7 @@ const records = await xata.search.all('new st', {
```

```python
records = xata.data().search_branch({
results = xata.data().search_branch({
"query": "new st",
"tables": [
{
Expand Down Expand Up @@ -559,7 +561,7 @@ You can assign an integer weight to each column. The default weight is 1. The hi
<TabbedCode tabs={['TypeScript', 'Python', 'JSON']}>

```ts
const records = await xata.search.all('matrix', {
const results = await xata.search.all('matrix', {
tables: [
{
table: 'Posts',
Expand All @@ -570,7 +572,7 @@ const records = await xata.search.all('matrix', {
```

```python
records = xata.data().search_branch({
results = xata.data().search_branch({
"query": "matrix",
"tables": [
{
Expand Down Expand Up @@ -627,7 +629,7 @@ contain metrics relevant for the relevancy, like "number of stars", or "number o
<TabbedCode tabs={['TypeScript', 'Python', 'JSON']}>

```ts
const records = await xata.search.all('matrix', {
const results = await xata.search.all('matrix', {
tables: [
{
table: 'Posts',
Expand All @@ -638,7 +640,7 @@ const records = await xata.search.all('matrix', {
```

```python
records = xata.data().search_branch({
results = xata.data().search_branch({
"query": "matrix",
"tables": [
{
Expand Down Expand Up @@ -699,7 +701,7 @@ The modifier parameter options are:
<TabbedCode tabs={['TypeScript', 'Python', 'JSON']}>

```ts
const records = await xata.search.all('matrix', {
const results = await xata.search.all('matrix', {
tables: [
{
table: 'Posts',
Expand All @@ -710,7 +712,7 @@ const records = await xata.search.all('matrix', {
```

```python
records = xata.data().search_branch({
results = xata.data().search_branch({
"query": "matrix",
"tables": [
{
Expand Down Expand Up @@ -763,7 +765,7 @@ example, articles in a given category. Or you can use it to "pin" a particular r
<TabbedCode tabs={['TypeScript', 'Python', 'JSON']}>

```ts
const records = await xata.search.all('matrix', {
const results = await xata.search.all('matrix', {
tables: [
{
table: 'Posts',
Expand All @@ -774,7 +776,7 @@ const records = await xata.search.all('matrix', {
```

```python
records = xata.data().search_branch({
results = xata.data().search_branch({
"query": "matrix",
"tables": [
{
Expand Down Expand Up @@ -827,7 +829,7 @@ be used to boost, for example, more recent articles.
<TabbedCode tabs={['TypeScript', 'Python', 'JSON']}>

```ts
const records = await xata.search.all('matrix', {
const results = await xata.search.all('matrix', {
tables: [
{
table: 'Posts',
Expand All @@ -847,7 +849,7 @@ const records = await xata.search.all('matrix', {
```

```python
records = xata.data().search_branch({
results = xata.data().search_branch({
"query": "matrix",
"tables": [
{
Expand Down