Solr Querying Child document - solr

I normally use elasticsearch and I'm new to solr. How can I search zip codes in child documents in some code like below? Is it even possible?
{
name: "my Name",
phone: {
mobile: "(123) 456 7800",
mobile2: "(123) 456 7800"
},
Address:{
Home: {
address: "123 something way",
cs: "El Cerrito, CA",
zip: 99999
},
Work: {
address: "444 Goldriver drive",
cs: "Cool, CA",
zip: 88888
}
}
}

Related

How to place woocommerce order with meta_data with axios

i am creating a resturant delivery react native app using woocommerce api and trying to place an order with Woocommerce API using axios.
on the website, i can select a product, its optional dishes and place the order. and it creates successfully..
but in the app i do like this.
{
payment_method: "cod",
payment_method_title: "Cash On Delivery",
set_paid: true,
billing: {
first_name: "John",
last_name: "Doe",
address_1: "969 Market",
address_2: "",
city: "San Francisco",
state: "CA",
postcode: "94103",
country: "US",
email: "john.doe#example.com",
phone: "(555) 555-5555"
},
shipping: {
first_name: "John",
last_name: "Doe",
address_1: "969 Market",
address_2: "",
city: "San Francisco",
state: "CA",
postcode: "94103",
country: "US"
},
line_items: [
{
product_id: 1479,
quantity: 2
},
],
shipping_lines: [
{
method_id: "flat_rate",
method_title: "Flat Rate",
total: "10.00"
}
]
};
it creates the order successfully but only shows the side items without calculating the price. means only the basic price is shown on the order without adding the additional products.

Mongo database call returning incorrect data after reload

I am trying to sort some database entries based on a boolean representing if a job is "completed" or not. The mutation functionality is working every time according to the graphQL playground but when the database call is utilized in the application the boolean data console logs as true first but then quickly logs again as false. The playground returns the data as true every time, once it has been changed, but something inside the application is not playing nice. Me and my project partners are freshly out of a coding bootcamp and have been learning successfully at a pretty steady pace but have not been able to figure this one out. Any feedback is appreciated. Thanks!!
const { loading: userLoading, data } = useQuery(QUERY_ME_BASIC);
const { loading: jobsLoading, data: jobsData } = useQuery(GET_JOBS);
var user = {};
var jobs = [];
var completedJobs = [];
var incompleteJobs = [];
if (!userLoading) {
console.log(jobsData)
user = data.me;
}
if(!jobsLoading){
jobs = jobsData.jobs
}
if(jobs){
console.log(jobs)
for (let i = 0; i < jobs.length; i++) {
if (jobs[i].completed === false) {
incompleteJobs.push(jobs[i]);
}
}
}
Query Response (GET_JOBS) from Graphql playground
{
"data": {
"jobs": [
{
"id": "47",
"_id": "6107fce77f7afc40e4e185a7",
"date": "2021-08-17",
"category": "Yard Waste",
"description": "addas",
"distance": "1.585",
"taken": true,
"completed": true,
"phone": "6153050246",
"email": "wfh2d88#gmail.com",
"driverEmail": "wfh2d88#gmail.com",
"createdAt": "Aug 2nd, 2021 at 9:10 am",
"pickup": {
"address": "207 Porter Village Circle",
"address2": "A",
"city": "Nashville",
"state": "Tennessee",
"zip": "37206",
"lat": "36.182571",
"lng": "-86.733267"
},
"dropoff": {
"address": "1800 Stratford Ave",
"address2": "A",
"city": "Nashville",
"state": "Alabama",
"zip": "37206",
"lat": "36.198164",
"lng": "-86.717083"
}
}
]
}
}
console.log(job) after Job Completion (3 appear one quickly after the other). First Two:
0:
category: "Yard Waste"
completed: true
createdAt: "Aug 2nd, 2021 at 9:10 am"
date: "2021-08-17"
description: "addas"
distance: "1.585"
driverEmail: "wfh2d88#gmail.com"
dropoff: {address: "1800 Stratford Ave", address2: "A", city: "Nashville", state: "Alabama", zip: "37206", …}
email: "wfh2d88#gmail.com"
id: "47"
phone: "6153050246"
pickup: {address: "207 Porter Village Circle", address2: "A", city: "Nashville", state: "Tennessee", zip: "37206", …}
taken: true
__typename: "Job"
_id: "6107fce77f7afc40e4e185a7"
[[Prototype]]: Object
length: 1
[[Prototype]]: Array(0)
Profile.js:32
Object
Profile.js:41
Last log from same line:
0:
category: "Yard Waste"
completed: false
createdAt: "Aug 2nd, 2021 at 9:10 am"
date: "2021-08-17"
description: "addas"
distance: "1.585"
driverEmail: "wfh2d88#gmail.com"
dropoff: {address: "1800 Stratford Ave", address2: "A", city: "Nashville", state: "Alabama", zip: "37206", …}
email: "wfh2d88#gmail.com"
id: "47"
phone: "6153050246"
pickup: {address: "207 Porter Village Circle", address2: "A", city: "Nashville", state: "Tennessee", zip: "37206", …}
taken: true
__typename: "Job"
_id: "6107fce77f7afc40e4e185a7"

Order of data returning from Monongodb

I am making a mongodb model>>
const mongoose = require('mongoose');
const {Schema} = mongoose;
const locationSchema = new Schema({
name: String,
Address: String,
ContactInfo: {
phone: Number,
email: String,
},
Website: String,
Hours: {
DaysOpen: String,
OpeningTime:[Number],
ClosingTime:[Number],
},
Services: String,
Languages: String,
Documentation: Boolean,
OtherNotes: String,
})
mongoose.model('Locations', locationSchema);
When I try and run a get request to see what is in my database I am returned
{
"error": false,
"location": {
"Hours": {
"OpeningTime": [
1215,
898
],
"ClosingTime": [
1400
],
"DaysOpen": "Sunday"
},
"_id": "5ee8fd2e57aa5126d4c1c854",
"name": "Evergreen Christian Center Food Pantry",
"Address": "4400 NW Glencoe Rd, Hillsboro, OR 97124",
"ContactInfo": {
"phone": 5033196590,
"email": "gonzocyn2#msn.com"
},
"Website": "https://www.ecc4.org/home",
"Services": "All foods available including meat and frozen foods",
"Languages": "English, Spanish",
"Documentation": false,
"OtherNotes": "Bring own bag or box. Sign up starts at 9:00am",
"__v": 0
}
The problem is that "Hours" is being displayed before the name, address, and contact info. This only occurs when I have the fields "OpeningTime" and "ClosingTime" as arrays. Any idea on how to fix this?

Object name/value array only returning 1 value, instead of 3

I have created an array that I am struggling to access. Can you help with this newb problem.
var Obj = [Companies :
{Company : "MPP",
Details : {Address : "test#test.com",
Phone : "something"},
Company : "UKP1",
Details : {Address : "test2#test.com",
Phone : "somethingelse"},
Company : "UKP2",
Details : {Address : "test3#test.com",
Phone : "something3else"}
}
]
//result0:
Obj.Companies;
{Company: "UKP2", Details: {…}}
//result1;
Obj.Companies[1];
VM1393:1 Uncaught SyntaxError: Unexpected token :
Can you tell me what I am missing to see this as an array.
I switched to object array as thought json array was messier, and had similar problems with that anyway.
I want to be able to use jquery.each() on the Obj.
ie. access the below in an array style.
obj.Companies[i].Company;
obj.Companies[i].Details.Address;
obj.Companies[i].Details.Phone;
Thanks for your help in advance :)
You need some changes to your object model (converting from array to object)
let Obj = {
Companies: [{
Company: "MPP",
Details: {
Address: "test#test.com",
Phone: "something"
}
},
{
Company: "UKP1",
Details: {
Address: "test2#test.com",
Phone: "somethingelse"
}
},
{
Company: "UKP2",
Details: {
Address: "test3#test.com",
Phone: "something3else"
}
}
]
}
console.log(Obj.Companies[1].Company);
console.log(Obj.Companies[1].Details.Address);
console.log(Obj.Companies[1].Details.Phone);
Hi first of all string values in JSON need to be enclosed in double inverted comas
and your Companies contain list of companies please make it array of objects as i shown below, it will work
{
"Companies": [{
"Company": "MPP",
"Details": {
"Address": "test#test.com",
"Phone": "something"
}
},
{
"Company": "UKP1",
"Details": {
"Address": "test2#test.com",
"Phone": "somethingelse"
}
},
{
"Company": "UKP2",
"Details": {
"Address": "test3#test.com",
"Phone": "something3else"
}
}
]
}

Reference Error : Object is not Defined While Accessing a Object with "|" in between Angular (Typescript)

Friends, I am Trying to Access an object out of a nested array, everything seems to be fine but I can't access one variable which includes a |
Below i am Showing the JSON Data.
var data = {
isbaggage: "true",
O: {
"BOM|DEL": {
uid: "1",
rph: "1",
baggageOptions: [
{
typ: "XC30",
desc: "30 kg",
amt: "11400",
curr: "INR",
convamt: "11400"
},
{
typ: "XC05",
desc: "5 kg",
amt: "1900",
curr: "INR",
convamt: "1900"
},
{
typ: "XC10",
desc: "10 kg",
amt: "3800",
curr: "INR",
convamt: "3800"
},
{
typ: "XC15",
desc: "15 kg",
amt: "5700",
curr: "INR",
convamt: "5700"
}
]
}
}
};
This is the code I am trying to access it with.
console.log(data.O.BOM|DEL);
This is the link of Sandbox link
Sandbox Link
You have to write this way,
console.log(data.O['BOM|DEL']);

Resources