kandi background
Explore Kits

Matisse | welldesigned local image and video selector | Android library

 by   zhihu Java Version: v0.5.3-beta3 License: Apache-2.0

 by   zhihu Java Version: v0.5.3-beta3 License: Apache-2.0

Download this library from

kandi X-RAY | Matisse Summary

Matisse is a Java library typically used in Mobile, Android applications. Matisse has no bugs, it has no vulnerabilities, it has build file available, it has a Permissive License and it has medium support. You can download it from GitHub.
Matisse is a well-designed local image and video selector for Android. You can.
Support
Support
Quality
Quality
Security
Security
License
License
Reuse
Reuse

kandi-support Support

  • Matisse has a medium active ecosystem.
  • It has 11984 star(s) with 1907 fork(s). There are 240 watchers for this library.
  • It had no major release in the last 12 months.
  • There are 383 open issues and 303 have been closed. On average issues are closed in 87 days. There are 54 open pull requests and 0 closed requests.
  • It has a neutral sentiment in the developer community.
  • The latest version of Matisse is v0.5.3-beta3
Matisse Support
Best in #Android
Average in #Android
Matisse Support
Best in #Android
Average in #Android

quality kandi Quality

  • Matisse has 0 bugs and 0 code smells.
Matisse Quality
Best in #Android
Average in #Android
Matisse Quality
Best in #Android
Average in #Android

securitySecurity

  • Matisse has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • Matisse code analysis shows 0 unresolved vulnerabilities.
  • There are 0 security hotspots that need review.
Matisse Security
Best in #Android
Average in #Android
Matisse Security
Best in #Android
Average in #Android

license License

  • Matisse is licensed under the Apache-2.0 License. This license is Permissive.
  • Permissive licenses have the least restrictions, and you can use them in most projects.
Matisse License
Best in #Android
Average in #Android
Matisse License
Best in #Android
Average in #Android

buildReuse

  • Matisse releases are available to install and integrate.
  • Build file is available. You can build the component from source.
  • Installation instructions, examples and code snippets are available.
  • Matisse saves you 2429 person hours of effort in developing the same functionality from scratch.
  • It has 5291 lines of code, 371 functions and 103 files.
  • It has medium code complexity. Code complexity directly impacts maintainability of the code.
Matisse Reuse
Best in #Android
Average in #Android
Matisse Reuse
Best in #Android
Average in #Android
Top functions reviewed by kandi - BETA

kandi has reviewed Matisse and discovered the below as its top functions. This is intended to give you an instant insight into Matisse implemented functionality, and help decide if they suit your requirements.

  • Start the action
  • Get the path for a document
  • Initializes the view .
  • Dispatch an image capture to the media store .
  • Set check status for the item .
  • Returns the orientation tag value of an exif file .
  • Called when a media item is selected .
  • Updates the bottom toolbar .
  • Returns the offsets of the items in the RecyclerView .
  • Creates and registers the media grid .

Matisse Key Features

Use it in Activity or Fragment

Select images including JPEG, PNG, GIF and videos including MPEG, MP4

Apply different themes, including two built-in themes and custom themes

Different image loaders

Define custom filter rules

More to find out yourself

Download

copy iconCopydownload iconDownload
repositories {
    jcenter()
}

dependencies {
    implementation 'com.zhihu.android:matisse:$latest_version'
}

ProGuard

copy iconCopydownload iconDownload
-dontwarn com.squareup.picasso.**

How do I use Matisse?

copy iconCopydownload iconDownload
Matisse.from(MainActivity.this)
        .choose(MimeType.allOf())
        .countable(true)
        .maxSelectable(9)
        .addFilter(new GifSizeFilter(320, 320, 5 * Filter.K * Filter.K))
        .gridExpectedSize(getResources().getDimensionPixelSize(R.dimen.grid_expected_size))
        .restrictOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED)
        .thumbnailScale(0.85f)
        .imageEngine(new GlideEngine())
        .showPreview(false) // Default is `true`
        .forResult(REQUEST_CODE_CHOOSE);

License

copy iconCopydownload iconDownload
Copyright 2017 Zhihu Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

MongoDB unable to lookup docs based on variable parent document property

copy iconCopydownload iconDownload
{
  $match: {
    _id: {
      $ne: "$$id"
    },
    $expr: {
      $eq: [
        "$detail.duration",
        "$$duration"
      ]
    }
  }
}

For loop to write data to file Java

copy iconCopydownload iconDownload
public void saveWorksToFile(OutputStreamWriter writer) {
    // write your code here
    JSONObject jsonObject = new JSONObject();
    try {
        jsonObject.put("ARTIST_NAME",this.name);
        jsonObject.put("NUM_WORKS",this.works.size());
        for (int i=0;i<works.size();i++) {
            jsonObject.put("work_" + i, works.get(i).toString());
            // you can save work as a byte array or json string so you could easily import the data back
        }

        BufferedWriter buffer = new BufferedWriter(writer);
        buffer.write(jsonObject.toString()+"\n");
        buffer.close();
    }
    catch (IOException | JSONException e) {
        System.out.println("IOException occurred");
    }
}
public Artist readFromFile(File file){
    Artist artist = null;
    FileReader fileReader = null;
    String line= null;
    BufferedReader bufferedReader;
    try {
        fileReader = new FileReader(file);

        bufferedReader = new BufferedReader(fileReader);
        
        line = bufferedReader.readLine();


        while (line != null){
            line += "\n";

            JSONObject jsonObject  = null;
            try {
                jsonObject = new JSONObject(line);

                String name = jsonObject.get("ARTIST_NAME").toString();
                int works_num = Integer.parseInt(jsonObject.get("NUM_WORKS").toString());
                // here you can import the works as a string.


                artist = new Artist(name);


            } catch (JSONException e) {
                e.printStackTrace();
            }

            line = bufferedReader.readLine();

        }

        bufferedReader.close();

    } catch (IOException e) {
        e.printStackTrace();
    }
    return artist;
}
-----------------------
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;


public class Artist {

    private String name; // e.g. "Henri Matisse"
    private List<Work> works = new ArrayList<>();

    public Artist(String name) {
        this.name = name;
    }

    public void addWork(Work  work) {
        this.works.add(work);
    }

    public void saveWork(){
        try{
            BufferedWriter writer = new BufferedWriter(
                    new FileWriter("path where want to save"));
            writer.write(this.name);
            writer.newLine();
            writer.write("works: " + this.works.size());
            writer.newLine();

            this.works.forEach(work -> {
                try {
                    writer.write(work.name);
                    writer.newLine();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            });

            writer.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }


}

public class Work {
    String name; // e.g. "Mona Lisa"
    int yearCreated; // e.g. 1506
    String medium; // e.g. "Oil on poplar panel"

    public Work(String name, int yearCreated, String medium) {
        this.name = name;
        this.yearCreated = yearCreated;
        this.medium = medium;
    }

    public String getName() { return name; }
    public int getYearCreated() { return yearCreated; }
    public String getMedium() { return medium; }



    @Override
    public String toString() {
        return name + "|" + yearCreated + "|" + medium;
    }
}



public class Main {
    public static void main(String[] args) {

        Work work1 = new Work("Fast1",2019,"ss");
        Work work2 = new Work("Fast2",2019,"ss");

        Artist artist = new Artist("Artist_Tom_Cruise");
        artist.addWork(work1);
        artist.addWork(work2);

        artist.saveWork();
    }
}


-----------------------
public void saveWorksToFile(Writer writer) {
    try {
        writer.write(this.name);
        writer.write(System.lineSeparator());
        writer.write("works: " + this.works.size());
        writer.write(System.lineSeparator());
        writer.write("---");
        writer.write(System.lineSeparator());
        boolean first = true;
        for (Work work : works) {
            if (first) {
                first = false;
            }
            else {
                writer.write(System.lineSeparator());
            }
            writer.write(work.toString());
        }
    }
    catch (IOException e) {
        System.out.println("IOException occurred");
    }
}
/**
 * import java.io.StringWriter
 */
public static void main(String[] args) {
    Artist artist = new Artist("Vincent van Gogh");
    StringWriter sw = new StringWriter();
    artist.saveWorksToFile(sw);
    System.out.print(sw);
    System.out.println();
    artist = new Artist("Claude Monet");
    Work work = new Work("Bridge over a Pond of Water Lilies", 1899, "Oil on canvas");
    artist.addWork(work);
    work = new Work("Impression, Sunrise", 1872, "Oil on canvas");
    artist.addWork(work);
    sw = new StringWriter();
    artist.saveWorksToFile(sw);
    System.out.print(sw);
    System.out.println();
    artist = new Artist("Henri Matisse");
    work = new Work("Woman with a Hat", 1905, "Oil on canvas");
    artist.addWork(work);
    sw = new StringWriter();
    artist.saveWorksToFile(sw);
    System.out.print(sw);
}
Vincent van Gogh
works: 0
---

Claude Monet
works: 2
---
Bridge over a Pond of Water Lilies|1899|Oil on canvas
Impression, Sunrise|1872|Oil on canvas
Henry Matisse
works: 1
---
Woman with a Hat|1905|Oil on canvas
-----------------------
public void saveWorksToFile(Writer writer) {
    try {
        writer.write(this.name);
        writer.write(System.lineSeparator());
        writer.write("works: " + this.works.size());
        writer.write(System.lineSeparator());
        writer.write("---");
        writer.write(System.lineSeparator());
        boolean first = true;
        for (Work work : works) {
            if (first) {
                first = false;
            }
            else {
                writer.write(System.lineSeparator());
            }
            writer.write(work.toString());
        }
    }
    catch (IOException e) {
        System.out.println("IOException occurred");
    }
}
/**
 * import java.io.StringWriter
 */
public static void main(String[] args) {
    Artist artist = new Artist("Vincent van Gogh");
    StringWriter sw = new StringWriter();
    artist.saveWorksToFile(sw);
    System.out.print(sw);
    System.out.println();
    artist = new Artist("Claude Monet");
    Work work = new Work("Bridge over a Pond of Water Lilies", 1899, "Oil on canvas");
    artist.addWork(work);
    work = new Work("Impression, Sunrise", 1872, "Oil on canvas");
    artist.addWork(work);
    sw = new StringWriter();
    artist.saveWorksToFile(sw);
    System.out.print(sw);
    System.out.println();
    artist = new Artist("Henri Matisse");
    work = new Work("Woman with a Hat", 1905, "Oil on canvas");
    artist.addWork(work);
    sw = new StringWriter();
    artist.saveWorksToFile(sw);
    System.out.print(sw);
}
Vincent van Gogh
works: 0
---

Claude Monet
works: 2
---
Bridge over a Pond of Water Lilies|1899|Oil on canvas
Impression, Sunrise|1872|Oil on canvas
Henry Matisse
works: 1
---
Woman with a Hat|1905|Oil on canvas
-----------------------
public void saveWorksToFile(Writer writer) {
    try {
        writer.write(this.name);
        writer.write(System.lineSeparator());
        writer.write("works: " + this.works.size());
        writer.write(System.lineSeparator());
        writer.write("---");
        writer.write(System.lineSeparator());
        boolean first = true;
        for (Work work : works) {
            if (first) {
                first = false;
            }
            else {
                writer.write(System.lineSeparator());
            }
            writer.write(work.toString());
        }
    }
    catch (IOException e) {
        System.out.println("IOException occurred");
    }
}
/**
 * import java.io.StringWriter
 */
public static void main(String[] args) {
    Artist artist = new Artist("Vincent van Gogh");
    StringWriter sw = new StringWriter();
    artist.saveWorksToFile(sw);
    System.out.print(sw);
    System.out.println();
    artist = new Artist("Claude Monet");
    Work work = new Work("Bridge over a Pond of Water Lilies", 1899, "Oil on canvas");
    artist.addWork(work);
    work = new Work("Impression, Sunrise", 1872, "Oil on canvas");
    artist.addWork(work);
    sw = new StringWriter();
    artist.saveWorksToFile(sw);
    System.out.print(sw);
    System.out.println();
    artist = new Artist("Henri Matisse");
    work = new Work("Woman with a Hat", 1905, "Oil on canvas");
    artist.addWork(work);
    sw = new StringWriter();
    artist.saveWorksToFile(sw);
    System.out.print(sw);
}
Vincent van Gogh
works: 0
---

Claude Monet
works: 2
---
Bridge over a Pond of Water Lilies|1899|Oil on canvas
Impression, Sunrise|1872|Oil on canvas
Henry Matisse
works: 1
---
Woman with a Hat|1905|Oil on canvas

onActivityResult is deprecated in DialogFragments but not in Activity

copy iconCopydownload iconDownload
// You can do the assignment inside onAttach or onCreate, i.e, before the activity is displayed
    ActivityResultLauncher<Intent> someActivityResultLauncher = registerForActivityResult(
            new ActivityResultContracts.StartActivityForResult(),
            new ActivityResultCallback<ActivityResult>() {
                @Override
                public void onActivityResult(ActivityResult result) {
                    if (result.getResultCode() == Activity.RESULT_OK) {
                        // There are no request codes
                        Intent data = result.getData();
                        doSomeOperations();
                    }
                }
            });

    public void openSomeActivityForResult() {
        Intent intent = new Intent(this, SomeActivity.class);
        someActivityResultLauncher.launch(intent);
    }

On hover img; highlight list items corresponding to img classes

copy iconCopydownload iconDownload
$('img').hover(function() {
  //get class split it and then generated comma seperated value..
  var classes = $(this).attr('class').split(" ").map(function(value) {
    return "li." + value;
  }).join(",")
  $(classes).addClass('highlight'); //add there classs
}, function() {
  $('ol > li').removeClass('highlight'); //remove class
});
.highlight {
  color: red;
}

img {
  width: 100px;
  height: 100px
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
<img src="https://lh3.googleusercontent.com/proxy/_Sy7qYNsid8VYlalMQG871VgqMl7gUa5BZQbM8Gc2LkHW5kogHgvSsaiEYA00L3xakszWexpCTPnjJlmFt9APyvrAyQmF7jhP1Wr_G6Yccu0FBKS4SlgNHWgdQ" class="year_2010 artist_picasso color_green">
<img src="https://lh3.googleusercontent.com/proxy/_Sy7qYNsid8VYlalMQG871VgqMl7gUa5BZQbM8Gc2LkHW5kogHgvSsaiEYA00L3xakszWexpCTPnjJlmFt9APyvrAyQmF7jhP1Wr_G6Yccu0FBKS4SlgNHWgdQ" class="year_2009 artist_matisse color_blue">
<ol>
  <h1>year</h1>
  <li class="year_2008">2008</li>
  <li class="year_2009">2009</li>
  <li class="year_2010">2010</li>
  <li class="year_2011">2011</li>
</ol>
<ol>
  <h1>artist</h1>
  <li class="year_DavidHockney">Hockney</li>
  <li class="artist_matisse">Matisse</li>
  <li class="artist_miro">Miro</li>
  <li class="artist_picasso">Picasso</li>
</ol>
<ol>
  <h1>color</h1>
  <li class="color_blue">Blue</li>
  <li class="color_green">Green</li>
  <li class="color_red">Red</li>
</ol>
-----------------------
$('img').hover(function() {
  //get class split it and then generated comma seperated value..
  var classes = $(this).attr('class').split(" ").map(function(value) {
    return "li." + value;
  }).join(",")
  $(classes).addClass('highlight'); //add there classs
}, function() {
  $('ol > li').removeClass('highlight'); //remove class
});
.highlight {
  color: red;
}

img {
  width: 100px;
  height: 100px
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
<img src="https://lh3.googleusercontent.com/proxy/_Sy7qYNsid8VYlalMQG871VgqMl7gUa5BZQbM8Gc2LkHW5kogHgvSsaiEYA00L3xakszWexpCTPnjJlmFt9APyvrAyQmF7jhP1Wr_G6Yccu0FBKS4SlgNHWgdQ" class="year_2010 artist_picasso color_green">
<img src="https://lh3.googleusercontent.com/proxy/_Sy7qYNsid8VYlalMQG871VgqMl7gUa5BZQbM8Gc2LkHW5kogHgvSsaiEYA00L3xakszWexpCTPnjJlmFt9APyvrAyQmF7jhP1Wr_G6Yccu0FBKS4SlgNHWgdQ" class="year_2009 artist_matisse color_blue">
<ol>
  <h1>year</h1>
  <li class="year_2008">2008</li>
  <li class="year_2009">2009</li>
  <li class="year_2010">2010</li>
  <li class="year_2011">2011</li>
</ol>
<ol>
  <h1>artist</h1>
  <li class="year_DavidHockney">Hockney</li>
  <li class="artist_matisse">Matisse</li>
  <li class="artist_miro">Miro</li>
  <li class="artist_picasso">Picasso</li>
</ol>
<ol>
  <h1>color</h1>
  <li class="color_blue">Blue</li>
  <li class="color_green">Green</li>
  <li class="color_red">Red</li>
</ol>
-----------------------
$('img').hover(function() {
  //get class split it and then generated comma seperated value..
  var classes = $(this).attr('class').split(" ").map(function(value) {
    return "li." + value;
  }).join(",")
  $(classes).addClass('highlight'); //add there classs
}, function() {
  $('ol > li').removeClass('highlight'); //remove class
});
.highlight {
  color: red;
}

img {
  width: 100px;
  height: 100px
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script>
<img src="https://lh3.googleusercontent.com/proxy/_Sy7qYNsid8VYlalMQG871VgqMl7gUa5BZQbM8Gc2LkHW5kogHgvSsaiEYA00L3xakszWexpCTPnjJlmFt9APyvrAyQmF7jhP1Wr_G6Yccu0FBKS4SlgNHWgdQ" class="year_2010 artist_picasso color_green">
<img src="https://lh3.googleusercontent.com/proxy/_Sy7qYNsid8VYlalMQG871VgqMl7gUa5BZQbM8Gc2LkHW5kogHgvSsaiEYA00L3xakszWexpCTPnjJlmFt9APyvrAyQmF7jhP1Wr_G6Yccu0FBKS4SlgNHWgdQ" class="year_2009 artist_matisse color_blue">
<ol>
  <h1>year</h1>
  <li class="year_2008">2008</li>
  <li class="year_2009">2009</li>
  <li class="year_2010">2010</li>
  <li class="year_2011">2011</li>
</ol>
<ol>
  <h1>artist</h1>
  <li class="year_DavidHockney">Hockney</li>
  <li class="artist_matisse">Matisse</li>
  <li class="artist_miro">Miro</li>
  <li class="artist_picasso">Picasso</li>
</ol>
<ol>
  <h1>color</h1>
  <li class="color_blue">Blue</li>
  <li class="color_green">Green</li>
  <li class="color_red">Red</li>
</ol>

Java JTable enabled but not editable with a TableCellRenderer and a defaultTableModel

copy iconCopydownload iconDownload
public class MyTableModel extends DefaultTableModel
{
    @Override
    public boolean isCellEditable(int row, int column)
    {
        return false;
    }
}

Google play: We found ad SDKs in your app

copy iconCopydownload iconDownload
exclude group: 'com.google.android.gms', module : 'play-services-ads-identifier'

implementation ('com.google.firebase:firebase-core:18.0.3'){
        exclude group: 'com.google.android.gms', module : 'play-services-ads-identifier'
    }
    implementation ('com.google.firebase:firebase-invites:17.0.0'){
        exclude group: 'com.google.android.gms', module : 'play-services-ads-identifier'
    }
    implementation ('com.google.firebase:firebase-auth:20.0.3'){
        exclude group: 'com.google.android.gms', module : 'play-services-ads-identifier'
    }
    implementation ('com.google.firebase:firebase-messaging:21.1.0'){
        exclude group: 'com.google.android.gms', module : 'play-services-ads-identifier'
    }

implementation ('com.google.firebase:firebase-crashlytics:17.4.1'){
        exclude group: 'com.google.android.gms', module : 'play-services-ads-identifier'
    }
    implementation ('com.google.firebase:firebase-analytics:18.0.3'){
        exclude group: 'com.google.android.gms', module : 'play-services-ads-identifier'
    }

Can I use jQuery to toggle 'reversed' on an ordered list?

copy iconCopydownload iconDownload
$('section span').on('click', function(e) {
   var OlObj = $(this).parent('h1').next('ol');
   OlObj.append( OlObj.find('li').get().reverse());
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<section>
    <h1>artists <span>sort</span></h1>
    <ol>
        <li>Hockney, David</li>
        <li>Matisse, Henri</li>
        <li>Picasso, Pablo</li>
    </ol>
</section>
-----------------------
$('section span').on('click', function(e) {
   var OlObj = $(this).parent('h1').next('ol');
   OlObj.append( OlObj.find('li').get().reverse());
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<section>
    <h1>artists <span>sort</span></h1>
    <ol>
        <li>Hockney, David</li>
        <li>Matisse, Henri</li>
        <li>Picasso, Pablo</li>
    </ol>
</section>

how to remove doube square brackets in json array - nodejs

copy iconCopydownload iconDownload
maindata.detail = [...arra]; 
var arra = [{
    TableTitel: 'Sockel',
    TableValue: 'AM4 (PGA)'
  },
  {
    TableTitel: 'Codename',
    TableValue: 'Matisse'
  },
  {
    TableTitel: 'iGPU',
    TableValue: 'N/​A'
  }
];


var maindata = {
  podTitel: "AMD Ryzen 7 3700X, 8x 3.60GHz, boxed (100-100000071BOX)",
  podURL: "https://xml/amd-ryzen-7",
  podDesc: "Sockel: AM4 (PGA)",
  podStars: "4.9 von 5",
};

maindata.detail = [...arra]; 

console.log(maindata);
-----------------------
maindata.detail = [...arra]; 
var arra = [{
    TableTitel: 'Sockel',
    TableValue: 'AM4 (PGA)'
  },
  {
    TableTitel: 'Codename',
    TableValue: 'Matisse'
  },
  {
    TableTitel: 'iGPU',
    TableValue: 'N/​A'
  }
];


var maindata = {
  podTitel: "AMD Ryzen 7 3700X, 8x 3.60GHz, boxed (100-100000071BOX)",
  podURL: "https://xml/amd-ryzen-7",
  podDesc: "Sockel: AM4 (PGA)",
  podStars: "4.9 von 5",
};

maindata.detail = [...arra]; 

console.log(maindata);

Select Query: Error Code 1292 - Truncated incorrect DOUBLE value

copy iconCopydownload iconDownload
def show_entries(table, column):
    print(f"Here's the records in the table {table} and the column {column}.")
    mycursor.execute(f"SELECT {column} FROM {table}")
    myresult = mycursor.fetchall()
    for rec in myresult:
        print(rec)

Community Discussions

Trending Discussions on Matisse
  • MongoDB unable to lookup docs based on variable parent document property
  • For loop to write data to file Java
  • onActivityResult is deprecated in DialogFragments but not in Activity
  • On hover img; highlight list items corresponding to img classes
  • Java JTable enabled but not editable with a TableCellRenderer and a defaultTableModel
  • Google play: We found ad SDKs in your app
  • Can I use jQuery to toggle 'reversed' on an ordered list?
  • how to remove doube square brackets in json array - nodejs
  • Select Query: Error Code 1292 - Truncated incorrect DOUBLE value
Trending Discussions on Matisse

QUESTION

MongoDB unable to lookup docs based on variable parent document property

Asked 2022-Feb-20 at 11:36

I want to find products and for each product attach deals to it. A deal is a product from same collection, yet based on some common properties. So as per my requirement pipeline should return documents, for each document find other products those aren't same as current, but have equal detail.duration. But even though I've many docs with same duration, deals are always []. Could you please figure out the issue with my pipeline?

Following is the aggregation pipeline I'm running: I've added filter _id $in just for clarity based on shown documents below. This isn't a part of real pipeline $match query.

db.products
  .aggregate([
    {
      $match: {
        _id: {
          $in: [
            ObjectId("6210fa8746bee3fcbd0ad062"),
            ObjectId("6210fa7c46bee3fcbd0acc21"),
          ],
        },
        "detail.duration": { $gt: 0 },
      },
    },
    {
      $lookup: {
        from: "products",
        let: { id: "$_id", duration: "$detail.duration" },
        as: "deals",
        pipeline: [
          {
            $match: {
              _id: { $ne: "$id" },
              "detail.duration": "$duration",
            },
          },
          { $project: { detail: 1 } },
          { $limit: 1 },
        ],
      },
    },
    { $limit: 2 },
    { $project: { deals: 1 } },
  ])
  .pretty();

This was the result:

{ "_id" : ObjectId("6210fa7c46bee3fcbd0acc21"), "deals" : [ ] }
{ "_id" : ObjectId("6210fa8746bee3fcbd0ad062"), "deals" : [ ] }

Following are two example documents in the collection:

{
    "_id" : ObjectId("6210fa8746bee3fcbd0ad062"),
    "book" : "https://wegotrip.com/en/paris-d3/muse-d-orsay-and-musee-de-l-orangerie-combined-tour-ticket-p1117/?SUB_ID=336264",
    "address" : "Rue de Lille, 62bis",
    "countryName" : "France",
    "cityName" : "Paris",
    "location" : {
        "lang" : 48.859886,
        "lat" : 2.3254821,
        "country" : ObjectId("6210fa7746bee3fcbd0aca20"),
        "city" : ObjectId("6210fa7746bee3fcbd0aca1c"),
        "location" : "Rue de Lille, 62bis",
        "_id" : ObjectId("6210fa8746bee3fcbd0ad063")
    },
    "includes" : [
        {
            "value" : "Skip-the-line ticket to Orsay Museum",
            "included" : true
        },
        {
            "value" : "Skip-the-line ticket to the Musée de l'Orangerie",
            "included" : true
        },
        {
            "value" : "Detailed description of the Nymphéas from Claude Monet",
            "included" : true
        },
        {
            "value" : "Interesting stories of many great artists and their lives",
            "included" : true
        },
        {
            "value" : "An easy walkthrough of the Musée d'Orsay and the Musée de l'Orangerie and their great collection",
            "included" : true
        },
        {
            "value" : "Headphones — you should bring your own",
            "included" : false
        }
    ],
    "price" : {
        "priceConcession" : null,
        "priceChild" : null,
        "price" : 57,
        "currency" : ObjectId("6210fa7746bee3fcbd0aca2f"),
        "_id" : ObjectId("6210fa8746bee3fcbd0ad064")
    },
    "detail" : {
        "isPass" : false,
        "features" : [
            {
                "key" : "audio_guide",
                "value" : "Audio Guide"
            }
        ],
        "highlights" : [
            "Admire the masterpieces by Monet, Renoir, Degas, Cézanne, and many more",
            "Discover one of the finest collections of Impressionist art in the world",
            "Visit the Nymphéas by Monet, one of the greatest pieces of Impressionism",
            "Explore the Guillaume and Walter collection and find out what makes it unique"
        ],
        "details" : [ ],
        "images" : [
            {
                "id" : 7270,
                "description" : "",
                "cover" : false,
                "preview" : "https://app.wegotrip.com/media/CACHE/images/store/1117/dsc04800/01d0770dcc0cac4c6de0f6eae70742f6.jpg",
                "full" : "https://app.wegotrip.com/media/store/1117/dsc04800.jpg"
            },
            {
                "id" : 7269,
                "description" : "",
                "cover" : false,
                "preview" : "https://app.wegotrip.com/media/CACHE/images/store/1117/nympheasannees30salle1parisiennephotorogerviolet/e1270aef1c01391290df71d1f83c8abc.jpg",
                "full" : "https://app.wegotrip.com/media/store/1117/nympheasannees30salle1parisiennephotorogerviolet.jpg"
            },
            {
                "id" : 7268,
                "description" : "",
                "cover" : false,
                "preview" : "https://app.wegotrip.com/media/CACHE/images/store/1117/ob1f7c80dsc02414-large/7712cb29e133ee3acb4b2bffbc2ac654.jpg",
                "full" : "https://app.wegotrip.com/media/store/1117/ob1f7c80dsc02414-large.jpg"
            },
            {
                "id" : 7267,
                "description" : "",
                "cover" : false,
                "preview" : "https://app.wegotrip.com/media/CACHE/images/store/1117/tuileriesgardensb16dsc00678talrg/47430ab8a257e3ccd2337d7a0d750c57.jpg",
                "full" : "https://app.wegotrip.com/media/store/1117/tuileriesgardensb16dsc00678talrg.jpg"
            },
            {
                "id" : 7266,
                "description" : "",
                "cover" : false,
                "preview" : "https://app.wegotrip.com/media/CACHE/images/store/1117/009/54223ef27aac5cd94fe5c20893abf2de.jpg",
                "full" : "https://app.wegotrip.com/media/store/1117/009.jpg"
            },
            {
                "id" : 7264,
                "description" : "",
                "cover" : false,
                "preview" : "https://app.wegotrip.com/media/CACHE/images/store/1117/monet-morning-with-weeping-willow/09bf842cc9a9d7eade8d0739f704699f.jpg",
                "full" : "https://app.wegotrip.com/media/store/1117/monet-morning-with-weeping-willow.jpg"
            }
        ],
        "duration" : 2,
        "_id" : ObjectId("6210fa8746bee3fcbd0ad065")
    },
    "availability" : null,
    "subcategory" : [
        {
            "id" : 6,
            "title" : "Sightseeing Tickets & Passes",
            "slug" : "sightseeing-tickets-passes"
        }
    ],
    "category" : [
        {
            "id" : 6,
            "title" : "Sightseeing Tickets & Passes",
            "slug" : "sightseeing-tickets-passes"
        }
    ],
    "type" : "Audio Guide",
    "description" : "Visit the famous Musee d'Orsay and Musée de l'Orangerie in Paris with this combined self-guided tour! \r\n\r\nNavigate through the maze of exhibition rooms with mobile app and see a collection of works by the Impressionists and Expressionists – Seurat, Cezanne, Gaugin, Monet, Renoir, Manet, Van Gogh, Degas; sculptors like Rodin, Pompon and others. Check out a mini-version of the Statue of Liberty! \r\n\r\nExplore the Nymphéas paintings by Claude Monet, that is called \"the Sistine chapel of Impressionism\". Admire the great works of Picasso, Soutine, Rousseau, Matisse and many others part of the Paul Guillaume and Jean Walter collection. Learn about the style and private life of the artists.\r\n\r\nThe audio-guide will provide you with all the information on the cultural significance of these paintings. Walking through rooms you will understand how revolutionary for those times Manet’s, Cezanne’s and Degas’ creation really was casting doubts on conservative, academic conceptions of 'true art' and offering new techniques and ideas.",
    "thumbnail" : "https://app.wegotrip.com/media/CACHE/images/store/1117/013/c0b8cce52cb61ab1f30872e6e93385b4.jpg",
    "name" : "Musée d'Orsay/Musée de l'Orangerie Combined Admission Ticket & Audio Tour",
    "attractionDescription" : "",
    "attractionName" : "Musée d'Orsay & Musée de l'Orangerie",
    "attraction" : ObjectId("6210fa8746bee3fcbd0ad056"),
    "provider" : {
        "rating" : {
            "count" : 0,
            "average" : null,
            "_id" : ObjectId("6210fa8746bee3fcbd0ad067")
        },
        "preview" : "https://app.wegotrip.com/media/CACHE/images/store/1117/013/c0b8cce52cb61ab1f30872e6e93385b4.jpg",
        "slug" : "muse-d-orsay-and-musee-de-l-orangerie-combined-tour-ticket",
        "id" : "1117",
        "key" : "1",
        "_id" : ObjectId("6210fa8746bee3fcbd0ad066")
    },
    "__v" : 0
}
{
    "_id" : ObjectId("6210fa7c46bee3fcbd0acc21"),
    "book" : "https://wegotrip.com/en/barcelona-d1/the-dali-museum-in-figueres-p3/?SUB_ID=336264",
    "address" : "Pujada del Castell, 43",
    "countryName" : "Spain",
    "cityName" : "Barcelona",
    "location" : {
        "lang" : 42.26829425831263,
        "lat" : 2.95884132385254,
        "country" : ObjectId("6210fa7746bee3fcbd0aca3e"),
        "city" : ObjectId("6210fa7746bee3fcbd0aca3a"),
        "location" : "Pujada del Castell, 43",
        "_id" : ObjectId("6210fa7c46bee3fcbd0acc22")
    },
    "includes" : [
        {
            "value" : "Recommendations of places to visit to understand the life of Dali better",
            "included" : true
        },
        {
            "value" : "Skip-the-line ticket to Dali Theatre-Museum",
            "included" : true
        },
        {
            "value" : "Headphones — you should bring your own",
            "included" : false
        }
    ],
    "price" : {
        "priceConcession" : null,
        "priceChild" : null,
        "price" : 33,
        "currency" : ObjectId("6210fa7746bee3fcbd0aca2f"),
        "_id" : ObjectId("6210fa7c46bee3fcbd0acc23")
    },
    "detail" : {
        "isPass" : false,
        "features" : [
            {
                "key" : "audio_guide",
                "value" : "Audio Guide"
            }
        ],
        "highlights" : [
            "Discover Dali's surrealism starting with the building of the museum — it's definitely one of a kind",
            "Inside the museum you'll find the most famous and controversial works of the artist",
            "Our tour will provide you with insights and exiting facts about Dali's works"
        ],
        "details" : [ ],
        "images" : [
            {
                "id" : 6916,
                "description" : "",
                "cover" : false,
                "preview" : "https://app.wegotrip.com/media/CACHE/images/store/3/figueres-oleguer2/032b55c27bb2cd119bdc7fe6c4b86491.jpeg",
                "full" : "https://app.wegotrip.com/media/store/3/figueres-oleguer2.jpeg"
            },
            {
                "id" : 6915,
                "description" : "",
                "cover" : false,
                "preview" : "https://app.wegotrip.com/media/CACHE/images/store/3/sky-monument-statue-golden-museum-yellow-1156442-pxherecom/28c645449a9f45ec1e8ede7b7ffbe30f.jpg",
                "full" : "https://app.wegotrip.com/media/store/3/sky-monument-statue-golden-museum-yellow-1156442-pxherecom.jpg"
            },
            {
                "id" : 6914,
                "description" : "",
                "cover" : false,
                "preview" : "https://app.wegotrip.com/media/CACHE/images/store/3/architecture-window-museum-landmark-surrealism-catalonia-800928-pxherecom/43691ba6aecc2ee084c300c150e32a03.jpg",
                "full" : "https://app.wegotrip.com/media/store/3/architecture-window-museum-landmark-surrealism-catalonia-800928-pxherecom.jpg"
            },
            {
                "id" : 831,
                "description" : "",
                "cover" : false,
                "preview" : "https://app.wegotrip.com/media/CACHE/images/store/3/figueres-oleguers3k6yoz/b9c3093c79cf50e621e022706af59ad6.jpg",
                "full" : "https://app.wegotrip.com/media/store/3/figueres-oleguers3k6yoz.jpg"
            },
            {
                "id" : 832,
                "description" : "",
                "cover" : false,
                "preview" : "https://app.wegotrip.com/media/CACHE/images/store/3/shutterstock82210018/2a2450d4f75edf4549d36f2286b6f19b.jpg",
                "full" : "https://app.wegotrip.com/media/store/3/shutterstock82210018.jpg"
            },
            {
                "id" : 833,
                "description" : "",
                "cover" : false,
                "preview" : "https://app.wegotrip.com/media/CACHE/images/store/3/dali-museum-8983261920/aa0d93e475c7b7388bee88ff14f8d795.jpg",
                "full" : "https://app.wegotrip.com/media/store/3/dali-museum-8983261920.jpg"
            },
            {
                "id" : 834,
                "description" : "",
                "cover" : false,
                "preview" : "https://app.wegotrip.com/media/CACHE/images/store/3/shutterstock196896461/74fc427d0a27f0aa199ed24f4c51bcc5.jpg",
                "full" : "https://app.wegotrip.com/media/store/3/shutterstock196896461.jpg"
            }
        ],
        "duration" : 2,
        "_id" : ObjectId("6210fa7c46bee3fcbd0acc24")
    },
    "availability" : null,
    "subcategory" : [
        {
            "id" : 3,
            "title" : "Theme Tours",
            "slug" : "theme-tours"
        },
        {
            "id" : 1,
            "title" : "Culture & History",
            "slug" : "culture-and-history"
        },
        {
            "id" : 6,
            "title" : "Sightseeing Tickets & Passes",
            "slug" : "sightseeing-tickets-passes"
        }
    ],
    "category" : [
        {
            "id" : 3,
            "title" : "Theme Tours",
            "slug" : "theme-tours"
        },
        {
            "id" : 1,
            "title" : "Culture & History",
            "slug" : "culture-and-history"
        },
        {
            "id" : 6,
            "title" : "Sightseeing Tickets & Passes",
            "slug" : "sightseeing-tickets-passes"
        }
    ],
    "type" : "Audio Guide",
    "description" : "The Dalí Theatre and Museum is a museum of the artist Salvador Dalí in his home town of Figueres, in Catalonia, Spain. Dalí is buried there in a crypt below the stage. \r\n\r\nImmerse yourself in an exciting journey through the world of the genius of surrealism. Reveal the meaning of his ambiguous creations and learn the history of the artist's life. Enjoy the unique world of Dali in this excursion.",
    "thumbnail" : "https://app.wegotrip.com/media/CACHE/images/store/001_Ispaniya_Figeras_Teatr-01/783c3a10c34eb40c29f14f704cd9c8d1.jpeg",
    "name" : "The Dali Theatre-Museum: Skip-the-Line & Audio Tour",
    "attractionDescription" : "",
    "attractionName" : "Dali Theatre and Museum",
    "attraction" : ObjectId("6210fa7c46bee3fcbd0acc15"),
    "provider" : {
        "rating" : {
            "count" : 0,
            "average" : null,
            "_id" : ObjectId("6210fa7c46bee3fcbd0acc26")
        },
        "preview" : "https://app.wegotrip.com/media/CACHE/images/store/001_Ispaniya_Figeras_Teatr-01/783c3a10c34eb40c29f14f704cd9c8d1.jpeg",
        "slug" : "the-dali-museum-in-figueres",
        "id" : "3",
        "key" : "1",
        "_id" : ObjectId("6210fa7c46bee3fcbd0acc25")
    },
    "__v" : 0
}

Both of the above have detail.duration set to 2 and as per query, these 2 should have each other considered as a deal and found in result docs, but query returns deals: [], an empty array. I'm unable to figure out the problem.

ANSWER

Answered 2022-Feb-20 at 11:36

From $match (Restrictions)

The $match query syntax is identical to the read operation query syntax; i.e. $match does not accept raw aggregation expressions. To include aggregation expression in $match, use a $expr query expression.

And you need to use $$ to get the variable value.

let

To reference variables in pipeline stages, use the "$$" syntax.

Change the $match stage in the pipeline as:

{
  $match: {
    _id: {
      $ne: "$$id"
    },
    $expr: {
      $eq: [
        "$detail.duration",
        "$$duration"
      ]
    }
  }
}

Source https://stackoverflow.com/questions/71193757

Community Discussions, Code Snippets contain sources that include Stack Exchange Network

Vulnerabilities

No vulnerabilities reported

Install Matisse

Check out Matisse releases to see more unstable versions.

Support

For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .

DOWNLOAD this Library from

Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

Explore Related Topics

Share this Page

share link
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

  • © 2022 Open Weaver Inc.