Altering a redis index to remove stopwords - redis

I'm using RediSearch and I would like to remove all the stop words, I can read in the documentation that it says to set the STOPWORDS to 0 using the FT.CREATE command, however, I have an already created index I would like to modify to remove the stopwords, how can I do that?

It seems the index has to be dropped and re-created with the STOPWORDS set to 0. I was using redis-om (for node) and I could turn off stopwords in the schema definition.
import { Schema } from 'redis-om';
const something = new Schema({
// ...options
}, {
useStopWords: 'OFF'
})
The above example disables the stop words for the index, and if it is already created, it will be re-made by the lib itself.
Thank you.

Related

Add value at the beginning of an array in react-native hook

I am functional component I am using hooks to update the state of the array locationData
const c = {
title: inputValue,
}
setLocationData([...locationData, c]);
This is working fine, but now I want to add the value at the beginning of the array, and not at the end.
Edit:
I also have a problem to delete an item from the array. I want to delete one item, but more are deleted
const deleteItem = (index) => {
console.log(index)
var temp = locationData;
var temp = locationData.splice(index, 1);
setLocationData(temp);
}
You are almost there, just switch the position in the array.
setLocationData([c, ...locationData]);
You should also be aware of other methods like splice, slice, push, pop etc...
Update: Using Splice
This relates to part 2 of your question with regards to removing from specific index.
The splice() method changes the contents of an array by removing or
replacing existing elements and/or adding new elements in place. To
access part of an array without modifying it, see slice().
So your codes should be similar to the following
var temp = [...locationData];
temp.splice(index, 1);
setLocationData(temp);

The Prismic fulltext predicate keeps giving me errors about unexpected fields when I Use it to try to query

I am trying to query with the Prismic predicate.fulltext using Vuejs
this is the first time am using the predicate but the documentation about what the fulltext predicate needs seems to be confusing. Here is my code.
async searchByQuery(query) {
const fullTextResult = await this.$prismic.client.get({
predicates: this.$prismic.predicate.not("articles.article_title", query),
});
console.log(fullTextResult);
},
where articles is my custom type and article_title is a field in my custom type.
That is what I understood from the documentation on how to do it but then I get an unexpected error
I would like a clarification on why this does not work and what the documentation really mean.
Am Using Vue3 by the way and that means am using the updated prismicio/client
You are pretty close!
Using Vue 3, you're looking at something like that:
export default {
methods: {
async searchByQuery(query) {
const fullTextResult = await this.$prismic.client.get({
predicates:
this.$prismic.predicate.fulltext(
"my.articles.article_title",
query
)
});
console.log(fullTextResult);
}
}
};
Basically, you need to prefix articles.article_title with my. to indicate it's a field on one of your document type, and change the predicate you're using to precidate.fulltext instead of predicate.not (assuming you want to run a fulltext search)
Let me know if that helps :)

Elasticsearch not accepting size

So I have a search created with elasticsearch request within Vuejs that runs great and all works but as soon as I add any size/from parameters into the query I get the error "Options contains invalid key: size" but I'm unsure of where it's going wrong. I have tried changing it to a get and I have tried rebuilding the query in several different ways but keep getting the same result.
let buildURL = 'https://blahblahblah.com/search';
const article = { query: query.query,
size: 50
};
const headers = {
'Authorization':'$token',
'Content-Type':'application/json',
};
let querydata = await $axios.$post(buildURL, article, { headers });
Options contains invalid key is not an error coming out of Elasticsearch directly. The component you're interacting with is called App Search and is a search engine layer on top of Elasticsearch.
So, all you need to change is the following:
const article = { query: query.query,
page: { size: 50 } <---- change this line
};
That should do the trick
passing of param size index option not define
Or there might be another option to get size , might be limit 0,50
Share interface file

Vue: Setting Data by matching route query

I'm attempting to set data fields provided by an array based on the Vue Router query. For example, when someone lands on my website using example.com/?location=texas, I want to set the location data by an array.
An example the array:
locations {
{
slug: "texas",
tagline: "Welcome to Texas",
}, {
slug: "california",
tagline: "Welcome to California",
}
}
I know this should be done using a computed property, however I am unable to get anything functioning. I've tried simple tests like if (this.slug.location === "texas"), and I cannot get the location data to populate. I would also like to provide default data in case there are no route matches.
Any help is extremely appreciated!
Edit:
I can accomplish this in a very manual way. Right now, I'm setting the query in data by the following:
slug: this.$route.query.location
I can display specific text by doing something like:
h3(v-if="slug === 'texas'") This will show for texas
h3(v-else-if="slug === 'california'") This will show for California
h3(v-else) This is default
The issue with this approach is there are various elements I need to customize depending on the slug. Is there any way I can create an array, and move whichever array matches a key in an array to the data??
You should be able to access a query param using the following (link to Vue Router documentation):
this.$route.query.location
So based on what you listed I would do something like...
export default {
computed: {
displayBasedOnLocationQueryParam() {
switch(this.$route.query.location) {
case 'texas':
return 'Welcome to Texas'
default:
return 'hello there, generic person'
}
}
}
}
Note that I'm not using your array explicitly there. The switch statement can be the sole source of that logic, if need be.

FaunaDB: How to create index for arbitrary length-array field

Is there a way to create an index for an array property of a document, so that I can Match the document based on any value in the array?
For example, assuming a document looks something like
{ data: { ips: ['192.168.1.1', '::ffff:c0a8:101'] } }
then I'd like to have an index documents_by_ip s.t. I can retrieve that document with either 192.168.1.1 or ::ffff:c0a8:101.
I was able to answer this question before even posting it. There are no extra steps required, just adding a field that is an array to the index terms will do exactly what I wanted to ~~~
CreateIndex('documents_by_id', { terms: [{ field: ['data', 'ips'] }] })