Elasticsearch not accepting size - vue.js

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

Related

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 :)

How to get over the limit of OpenSea Api?

I am trying to use OpenSea API and I noticed that I need to set a limit before retrieving assets
https://docs.opensea.io/reference/getting-assets
I figured I can use the offset to navigate through all the items, even though that's tedious. But the problem is offset itself has a limit, so are assets beyond the max offset inaccessible ?
I read that you that the API is "rate-limited" without an API key, so I assume that related to the number of requests you can make in a certain time period, am I correct about that? Or does it lift the limit of returned assets ? The documentation isn't clear about that https://docs.opensea.io/reference/api-overview
What can I do to navigate through all the assets ?
May be late answering this one, but I had a similar problem. You can only access a limited number (50) assets if using the API.
Using the API referenced on the page you linked to, you could do a for loop to grab assets of a collection in a range. For example, using Python:
import requests
def get_asset(collection_address:str, asset_id:str) ->str:
url = "https://api.opensea.io/api/v1/assets?token_ids="+asset_id+"&asset_contract_address="+collection_address+"&order_direction=desc&offset=0&limit=20"
response = requests.request("GET", url)
asset_details = response.text
return asset_details
#using the Dogepound collection with address 0x73883743dd9894bd2d43e975465b50df8d3af3b2
collection_address = '0x73883743dd9894bd2d43e975465b50df8d3af3b2'
asset_ids = [i for i in range(10)]
assets = [get_asset(collection_address, str(i)) for i in asset_ids]
print(assets)
For me, I actually used Typescript because that's what opensea use for their SDK (https://github.com/ProjectOpenSea/opensea-js). It's a bit more versatile and allows you to automate making offers, purchases and sales on assets. Anyway here's how you can get all of those assets in Typescript (you may need a few more dependencies than those referenced below):
import * as Web3 from 'web3'
import { OpenSeaPort, Network } from 'opensea-js'
// This example provider won't let you make transactions, only read-only calls:
const provider = new Web3.providers.HttpProvider('https://mainnet.infura.io')
const seaport = new OpenSeaPort(provider, {
networkName: Network.Main
})
async function getAssets(seaport: OpenSeaPort, collectionAddress: string, tokenIDRange:number) {
let assets:Array<any> = []
for (let i=0; i<tokenIDRange; i++) {
try {
let results = await client.api.getAsset({'collectionAddress':collectionAddress, 'tokenId': i,})
assets = [...assets, results ]
} catch (err) {
console.log(err)
}
}
return Promise.all(assets)
}
(async () => {
const seaport = connectToOpenSea();
const assets = await getAssets(seaport, collectionAddress, 10);
//Do something with assets
})();
The final thing to be aware of is that their API is rate limited, like you said. So you can only make a certain number of calls to their API within a time frame before you get a pesky 429 error. So either find a way of bypassing rate limits or put a timer on your requests.

Issue with getting data from an array of objects - vue.js / API / axios / proxy

First of all I'm using Vue.js to access data of an API using axios and a proxy
I'm trying to access the property of an object nested in the last array of several other arrays but I'm kinda hitting a wall, here's the detail :
Global details
the property I'm trying to access
I've tried different ways but here's my latest try :
axios
.get(proxyurl + history_url, {
reqHeaders
})
.then((reponse) => {
console.log(reponse.data)
this.lastItem = reponse.data.data.history[history.length-1]
console.log(this.lastItem)
this.lastEvol = this.lastItem.price
console.log(this.lastEvol)
})
The issue here is that the answer to "console.log(this.lastItem)" is :
lastItem answer
The value of the properties are now different and incorrect.
Since it's showing "Proxy" as the root object name I thought that may be the issue but I'm not sure.
I've tried several other ways to access this property but only had errors.
Any help would be greatly appreciated.
history is undefined in the history.length expression. Try this:
.then((reponse) => {
const history = reponse.data.data.history;
console.log(reponse.data)
this.lastItem = history[history.length-1]
console.log(this.lastItem)
this.lastEvol = this.lastItem.price
console.log(this.lastEvol)
})

How to grab apollo client cache content and use it in a query as an input type?

I am developing a react native application with apollo client and I need to have 2 screens:
Screen A: displays a list of profiles
Screen B: displays some filters which have to be applied to Screen A
So my idea was to use apollo client cache to save the state of the filters in screen B, and then come back to screen A and somehow refetch with the new filters applied.
Since there are a couple of filters that I need to send on each request to the server, I also was thinking about using an input type so I can send my filters in the form of an object instead of a list of comma-separated parameters.
So looking at the docs from apollo client, there is a section to manage the local stage. In there, I found a sub-section called Using #client fields as variables. Basically, this part tells you how to grab whatever filters were stored in the cache and send it as part of the query.
However, I always get the following error:
Invariant Violation: Missing selection set for an object of type ProfileParameters returned for query field profileParameters
some code:
This is how I initialized the cache-store, for now, it only contains page and pageSize but it will contain more parameters.
const cache = new InMemoryCache({
cacheRedirects: {
Query: {
profile: (_, {id}, {getCacheKey}) =>
getCacheKey({__typename: 'Profile', id: id}),
},
},
});
cache.writeData({
data: {
profileParameters: {
__typename: 'ProfileParameters',
page: 0,
pageSize: 25,
},
},
});
const client = new ApolloClient({
uri: 'http://192.168.1.102:3000/graphql',
cache: cache,
resolvers: {},
});
And this is the query component and the query:
const PROFILES_QUERY = gql`
query getFilteredProfiles($type: String, $parameters: ProfileParameters) {
profileParameters #client #export(as: "parameters")
profiles(type: $type, parameters: $parameters) {
id
name
termOfEntry
sport
sportPosition
gpa
avatarUrl
imageUrl
nationality
countryOfResidence
dateOfBirth
annualBudget
career
satScore
toeflScore
graduationDate
}
}
`;
<Query
query={PROFILES_QUERY}
variables={{
type: this.PROFILE_TYPE,
}}>
...
</Query>
There is a type variable that is being passed in the variables object. That comes from a local variable in the class.
Also, screen B does not exist yet, but the cache is being initialized and I want to read whatever is in there so I can send those filters to the server.

Retrieve the traffic variable in RankedReport of Adobe Sitecatalyst

Is it possible to fetch a traffic variable sProp1 along with PageName and Url when issuing a GetReport request of a Ranked report?
Let us say I have the following passed to SiteCatalyst (Omniture) via Java Script.
s.pageName = o_title; // Page Name
s.channel = o_structure; // SiteSection
s.prop1 = o_inode // Traffic variable also the Primary Key Id of the PageName
Now, if I run a RankedReport, I will get the following
PageName
PageViews
Url
Along with this info, I will also be interested in fetching the s.prop1 value. I will need the s.prop1 value to use it on my db to query the first sentence of the article from db (and other metadata) and show the results on the results page that shows the most popular pages. Can this be achieved? I mean is it possible to get the traffic variable associated with the pageName?
Thanks,
Rag
OK. I think I if I add another element (prop1) I get the breakdown. {
"reportDescription":{
"reportSuiteID":"*",
"dateFrom":"2013-03-06",
"dateTo":"2013-03-15",
"metrics":[
{
"id":"pageviews",
"name":"Page Views",
"type":"number"
}
],
"sortBy":"pageviews",
"elements":[
{
"id":"siteSection"
},
{
"id":"page"
},
{
"id":"prop1"
}
],
"locale":"en_US"
},
"validate":"false"
}