I currently have this code:
<li><h3 class="name">Mary Jefferson#</li>
<li><h3 class="name">grace.kelly#</li>
<li><h3 class="name">sandy.smith#</li>
<li><h3 class="name">mark.tommy#</li>
Because I use listjs to filter the results in a search box above it for the class "name", I don't want the "#jefferson.domain.us" to become part of the explicit line so as to prevent a false results in the use search for say "Jefferson".
How can I not repeat myself and get the "#jefferson.domain.us" to be usable in the mailto but not part of the search?
Related
Attempting to confirm that of all the schema in the head of a page exactly 3 of them should have a specific string within them. These schemas have no tags or sub classes to differentiate themselves from each other, only the text within them. I can confirm that the text exists within any of the schema:
cy.get('head > script[type="application/ld+json"]').should('contain', '"#type":"Product"')
But what I need is to confirm that that string exists 3 times, something like this:
cy.get('head > script[type="application/ld+json"]').contains('"#type":"Product"').should('have.length', 3)
And I can't seem to find a way to get this to work since .filter, .find, .contains, etc don't filter down the way I need them to. Any suggestions? At this point it seems like I either need to import a custom library or get someone to add ids to these specific schema. Thanks!
The first thing to note is that .contains() always yields a single result, even when many element match.
It's not very explicit in the docs, but this is what it says
Yields
.contains() yields the new DOM element it found.
If you run
cy.get('head > script[type="application/ld+json"]')
.contains('"#type":"Product"')
.then(console.log) // logs an object with length: 1
and open up the object logged in devtools you'll see length: 1, but if you remove the .contains('"#type":"Product"') the log will show a higher length.
You can avoid this by using the jQuery :contains() selector
cy.get('script[type="application/ld+json"]:contains("#type\": \"Product")')
.then(console.log) // logs an object with length: 3
.should('have.length', 3);
Note the inner parts of the search string have escape chars (\) for quote marks that are part of the search string.
If you want to avoid escape chars, use a bit of javascript inside a .then() to filter
cy.get('script[type="application/ld+json"]')
.then($els => $els.filter((index, el) => el.innerText.includes('"#type": "Product"')) )
.then(console.log) // logs an object with length: 3
.should('have.length', 3);
I am trying to get max & sum of two columns in a filter expression using MapboxGL-js. The two columns of interest may contain nulls.
Tried this for addition and it does not work (nothing shows up on the map)
["+",["to-number",['get', "col1"]],["to-number",['get', "col2"]]]
For max,I tried this and does not work either.
["max",["to-number",['get', "col1"]],["to-number",['get', "col2"]]]
Any suggestions? Thanks!
The filter defined in mapboxgl-js is
filter is a property at the layer level that determines which features should be rendered in a style layer.
In official mapboxgl-js example you can see that in case condition is true the feature will be rendered:
"filter": ["==", "icon", symbol]
where "icon" is equal to symbol (a variable that is set to the selected feature's icon property).
In your example there are no conditional operation done.
In case you are trying to show the "sum" or "max" as a layer's "text-field", you should use it there and not in filter, and return string after completing your Math operations.
so it will be
"test-field": ["to-string", ["max",["to-number", ["get", "col1"]],["to-number", ["get", "col2"] ]]],
Link to Filter Doc
Link to Expressions Docs
Hope this helps
I'm using NEST to create services, so I can search into a field (label)
Is there a way to get answers from a partial string ?
For example, if I have three labels : "John Doe" , "Dadido" and "Unicorn", if I type "Do", I get the two first ones
For now, I have this :
elasticClient.Search<ESbase>(s => s.Query(q=>q.Regexp(c =>
c.Name("label_query")
.Field(p =>p.Label).Value('*'+label+'*'))));
And when I try it, it doesn't send anything back
match: { text: '.*label.*'}should work
If you want use regex: Value(".*label.*")
I assume you used default maping and in your label string you dont have special character.
Edit: use wildcard work too .Wildcard("*label*")
I'm using Sphinx to index and search my website.
Is there a way to return excerpt (searched word and few words around it), when searching for some word.
Right now I'm using this package scalia.
$results = SphinxSearch::search($search, $index_type);
// I Set match, sort and ranking mode
$results
->setMatchMode($search_mode)
->setSortMode($sort_mode, $sort_column)
->setRankingMode(\Sphinx\SphinxClient::SPH_RANK_SPH04);
//set field weights
$results->setFieldWeights(array('title' => 10,'content'=> 5));
//and get results
$results = $results->limit(300, 0, 1000, 100000)->query();
Is there a way to manage Sphinx to return excerpt of text where it found searched keywords?
You need the BuildExcerpts function from the SphinxAPI
http://sphinxsearch.com/docs/current.html#api-func-buildexcerpts
Alas that extension, does not seem to expose the function, so would have to either modify the extension, or just bypass it.
For my acceptance testing I'm writing text into the auto complete extender and I need to click on the populated list.
In order to populate the list I have to use AppendText instead of TypeText, otherwise the textbox looses focus before the list is populated.
Now my problem is when I try to click on the populated list. I've tried searching the UL element and clicking on it; but it's not firing the click event on the list.
Then I tried to search the list by tagname and value:
Element element = Browser.Element(Find.By("tagname", "li") && Find.ByValue("lookupString"));
but it's not finding it, has anyone been able to do what I'm trying to do?
The shorter version of that is:
string lookupString = "string in list";
Element list = Browser.Element("li", Find.ByText(new Regex(lookupString)));
list.MouseDown();
Regexs will do a partial match so you don't need to specify .* either side and use string.Format. This assumes however that the lookupString doesn't contain any characters special to Regexs, they'd need to be escaped.
In case someone has the same problem. It works with the next code:
string lookupString = "string in list";
Regex lookup = new Regex(string.Format(".*{0}.*", lookupString));
Element list = Browser.Element("li", Find.ByText(lookup));
list.MouseDown();