excluding all documents that have indexed in a particular field elements that are not part of a given set - lucene.net

In my Lucene search I want to exclude all documents that have indexed in a particular field elements that are not part of a given set.
For example, lets say my document represents a drawing. and has a color field. In the color field I index all the colors that are used in a drawing. Now say I have access to say five colors. red, blue, green, purple, and brown. I want to only retrieve drawings that use these colors and any drawing that has a color not in the colors mentioned above should be excluded. If I want all drawings that use all these colors and nothing but all these colors, I can add a new field to my document for 'number of colors' and then build my Boolean query by adding MUST term queries for each of the colors and also adding a MUST Boolean query with the count as the number of colors. But I want to also retrieve all documents that have any combination of the 5 colors mentioned above. So a drawing that is done entirely with brown would also be retrieved.
Please note that I have thousands of colors. So creating a field for each color and then doing a MUST_NOT for everyone other than my 5 colors would also not be an option.
Many thanks!

I don't think there are built-in ways of doing that. Instead, you want to store the set of colors (that a particular drawing contains) somewhere. Then, as you go through each search result at search-time, you load the color set, check if it contains any of the "other" colors, and filter the result accordingly.
That somewhere can be any of at least two places:
Stored field: For example, you can store the color set as a comma-delimited list of color names as a String.
Term vector: If you index the color field with term vectors, then at search-time, you can call IndexReader.getTermFreqVector(int, String) to get the term vector information of that document/field. The resulting TermFreqVector object gives you a list (actually a set) of terms (i.e. colors in your case) in that field.

Related

Altair Scatter Chart

i am looking for a way to make a point chart based on multiple nominal conditions. i am plotting 2 values on x and y, but i would like to differentiate these points based on year as well as 'type'.
currently, the way i do it is to assign year to color while 'type' is assigned to shape
color=alt.condition(selection, alt.Color('Date:T'), alt.value('lightgray'), scheme='red' )
shape = alt.Shape('type:N')
a few questions:
is it possible to change the color scheme of the points instead of the default colors to say shades of red/blue/black, etc?
is it possible to assign one color scheme/shade (instead of shapes) to 'types'?
is it possible to change the color scheme of the points instead of the default colors to say shades of red/blue/black, etc?
Yes, see https://altair-viz.github.io/user_guide/customization.html#customizing-colors. You can use any of the built-in Vega color schemes, or define your own using the methods discussed there. From your example, it might look something like this:
color=alt.condition(
selection,
alt.Color('Date:T', scale=alt.Scale(scheme='reds')),
alt.value('lightgray')
)
is it possible to assign one color scheme/shade (instead of shapes) to 'types'?
No, there is no built-in way to apply two color scales based on two fields in the data (how would a mark choose between the two colors assigned to it?) One possible approach would be to use an opacity encoding for the second field, which is reflected in the lightness of the marks. For your example, it might look like this:
opacity='type:N'

How can I make each Packed Bubble a different color?

I have a Packed Bubble dashboard. My Y axis is a list of names and my X axis is a decimal. I want each differing number to be a different color. Can I do this manually?
If you want to color each bubble with a separate color just use the field that each bubble represent in the color shelf. If I understood your data correctly, each bubble basically represents one campaign, so you should use that as the color.
You can manually assign color using Color>Edit Color and assigning the color of your choice.
See image 1.
If you want to color your bubbles based on your measure AVg(NPV/Marketing $) you can do as Alex Blakemore mentioned and use your measure as a stepped color or gradient.
You can use Color>Edit Color here too , in this case manually assigning color is a bit difficult. But if you play with number of steps, the gradient pre-select, etc, you can usually get very close to what ever your wanted it to look like.
Put your numeric field on the color shelf, and either edit the colors to use a stepped set of colors - or change the field to be discrete and choose individual colors to taste.

Adjacent colors in swift

I'm using an API which returns images based on their color. I send a hex value, i.e. FF0000 and it returns images with that red color.
However, the API is rather too specific. For the above color for instance, I'd want to return all red stuff, not just that specific red.
Luckily the API allows a union of colors FF0000u0000FF is pure red and blue.
So what I need to do create an array of colors which surround the main color, so that I can pass it to the API,
How would I do this in Swift?
There are well over 16 million colours available in that colour space so I don't think that creating an array will be practical as there could easily be hundreds of thousands of 'reds' to add to that array. A better approach would be to adapt the api to compare a range of values of each separate channel so rather than red equating to FF0000, you would say that 'red' is any colour where the red channel is greater than 88 (HEX) and the other channels are less than 66 (HEX) for instance. It's a complex task that you're trying to achieve so it won't be a trivial job to solve it. If you share some code or a link to the API, someone may be able to give you more specific help.

How do you heatmap in tavleau a list of numbers based on another column data

I have data from 48 countries. I am trying to visualize it on a map. I want to display half the countries in 1 color and the other half in another color. This segmentation is based on another column which has string value 'yes' or 'no'. I want to do it on tableau
Country data OFF
------------------------
US 100,000 yes
IN 200,000 yes
BR 300,000 no
MX 150,000 no
I want to plot US, IN in Blue and BR, MX in green. The shades of green and blue are dependent on the values of data.
Have you tried to drag the OFF field to Color in the sheet? This should do the trick
You can put either the measure data on the color shelf to color by value, or the dimension OFF on the color shelf to color by OFF -- i.e. to use color to encode a single field's value.
If you want to color by two dimension fields, you can get the shading effect you mention by putting both on the color shelf -- using the shift key to add the second one if it's not in a hierarchy with the first one.
If you want to color by both a dimension and a measure (as in your case), you have to go to a little more effort -- assuming its worth it. You can make a calculated field that uses both fields to map into a category (say returning a string like "off yes, data high" or "off yes, data mid") and then edit the colors to map them as you like.

Controlling the color of text in an array based on a predefined condition

I am trying to display a matrix M of size 50x8 with a plot using text([x,y],M). All the entries in matrix are at present of the same color. I would like more control on the display, and would like that all matrix entries satisfying a particular condition should be of different color.
One of the possible ways to do is to specify the position for each of the elements of the matrix M individually in text(x,y,M_ij). But I am only specifying the position for the first element, and other positions are being assigned automatically. How can I get those positions, or control them? This will allow me to control the colors as well.
The resulting text graphics object is only one object, so you can't adjust the color through handle graphics without affecting all of the rows. But if it's possible for you, you can specify the color directly in the strings. To do this, you'll probably need to represent your strings as a cell array instead, so they can have different colors.
M = {'\color{red}Line 1';'\color{blue}Line 2';'\color[rgb]{.6 .8 .2}Line 3'};
text(1, 1, M);
The reference for other inline string markup is found on this doc page, in the 'String' property: http://www.mathworks.com/help/matlab/ref/text_props.html